+ -
当前位置:首页 → 问答吧 → 请教,一句SQL语句,判断是否有满足条件的记录

请教,一句SQL语句,判断是否有满足条件的记录

时间:2011-11-15

来源:互联网

请教,一句SQL语句,判断是否有满足条件的记录。判断A表中有满足condition的记录怎么写。
SQL code

select a.area, a.wg_rcuser, count(wg_code) doingitemcnt from v_qc_statistics a where wg_rctache = 1256 
and not exists (select wg_code from v_qc_statistics b where b.wg_srtache = 1256 and b.wg_sruser = a.wg_rcuser)
 group by area, wg_rcuser



其中,not exists后面挂号中的就是这个需要搞定的,剔除掉满足这样条件的记录

作者: shineheart   发布时间: 2011-11-15

这样写肯定木有记录,没看懂lz想干嘛

作者: tx2730   发布时间: 2011-11-15

SQL code
select a.area, a.wg_rcuser, count(wg_code) doingitemcnt 
from v_qc_statistics a 
where 
 not exists 
 (select 1 from v_qc_statistics b 
 where wg_rctache = 1256  NOT EXISTS( SELECT 1 FROM v_qc_statistics AS c WHERE c.wg_rcuser=b.wg_rcuser AND c.wg_srtache=a.wg_srtache)
 )
 group by area, wg_rcuser


作者: roy_88   发布时间: 2011-11-15

热门下载

更多