不显示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 )
起了过滤
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 )
起了过滤
相关文章推荐
- SQl不重复的所有数据(重复的只显示一条)
- SQL重复数据只显示一条
- SQL查询重复数据,只显示一条sql语句
- SQL查询重复数据,只显示一条sql语句
- SQL 查询重复数据并显示重复次数
- sql语句实现重复数据只显示一次 ,或者删除重复数据
- sql查询重复数据且显示出不同数据的重复次数并且排序
- SQL 查询重复数据并显示重复次数
- SQL 已更新或删除的行值要么不能使该行成为唯一行(sqlserver中有多行所有的列重复的数据,无法更新或删除问题)
- SQL:删除重复数据方法
- sql中多条重复数据只更新其中一条
- Mysql 查询部分字段重复数据sql语句
- oracle sql 当初始化数据时避免重复主键
- SQL 有条件地筛选重复数据
- oracle 数据库的管理工具 PL/SQL_Developer 的简易使用 与Java 连接并查询显示出数据
- sql 数据显示的顺序,要根据WHERE中输入的条件顺序来显示
- sql 实现相同记录的为空显示(重复内容不合并只将多余内容显示为空的小心得)
- sql按一列筛选,不显示重复行
- SQL删除重复数据只保留一条
- Oracle 查询重复数据的几种SQL