can someone help me converting this sql query into a stored proc..I am new to sql : Select OpportunityId 
from opportunity AS c 
    left JOIN (
        select a.opportunitynameid 
        from opportunity o
            JOIN ApprovalDocument a ON a.opportunitynameid=o.OpportunityId
    ) AS b ON c.OpportunityId=b.opportunitynameid
Where b.opportunitynameid IS NULL and statecode=0