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
答案 0 :(得分:0)
Create Procedure mySP_GetOpportunity
@statuscode int = 0
As
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=@statuscode
答案 1 :(得分:0)
在
CREATE PROCEDURE Proc_Name
AS
"query goes here"
GO
之间包装sql查询
有关详细信息,请参阅this