module query optimized with sub select

In this query I have used a sub query to pickup the tuples for the #__modules.