我能在SQL Server 2005的HAVING
语句中使用case语句吗?
以下是我的HAVING
语句,它给出了一个语法错误。
@CLIENTPK_NEW IS NULL OR
(
CLIENT.OH_PK = @CLIENTPK_NEW and
CASE WHEN @RelatedOrgs <> '11' then CLIENT.OH_PK= @CLIENTPK_NEW
ELSE CLIENT.OH_PK in (
SELECT dbo.OrgHeader.OH_PK FROM dbo.OrgHeader WITH (NOLOCK) INNER JOIN
dbo.OrgRelatedParty WITH (NOLOCK) ON dbo.OrgHeader.OH_PK = dbo.OrgRelatedParty.PR_OH_Parent INNER JOIN
dbo.OrgHeader AS OrgHeader_1 WITH (NOLOCK) ON dbo.OrgRelatedParty.PR_OH_RelatedParty = OrgHeader_1.OH_PK
where OrgHeader_1.OH_PK = @CLIENTPK_NEW
)
END
)
}
AND (@CGNEEPK IS NULL OR CGNEE.OH_PK = @CGNEEPK) AND
part.OP_RH_NKCommodityCode = @type
感谢您,Amit。
谢谢,