您的位置:首页 > 数据库

不显示sql重复数据行

2009-04-21 15:09 253 查看
Code
SELECT
D.[SourceId]
,D.[RepCode]
,D.[SourceBus]
,D.[PolicyType]
,D.[Discount]
,D.[CommRate] as CommisionRate
,D.[SourceCode]
,D.[StartDate]
,D.[EndDate]
,D.[CreateDate]
,D.[CoverType]
,C.[ID]
,C.[CreditLimit]
,C.[CreateDate]
,C.[CreatedBy]
,C.[LastUpdatedDate]
,C.[UpdatedBy]
,C.[Email]
FROM [WBISCommon].[dbo].[WBIS_CommDisc] D,
[WBIS2].[dbo].[CreditLimit] C
Where
D.RepCode = C.RepCode AND
D.SourceCode = C.SourceCode AND
D.PolicyType = 'GTT' AND
D.CoverType in ('P','A') AND
D.SourceCode Like '%' + @pValue +'%'
OR D.SourceBus Like '%' + @pValue +'%'
AND not exists(select 1 from [WBISCommon].[dbo].[WBIS_CommDisc]
where RepCode=c.RepCode )
END

关键在于 not exists(select 1 from [WBISCommon].[dbo].[WBIS_CommDisc]
where RepCode=c.RepCode )

起了过滤
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: