如何比较出查询1的结果集中有而查询2结果集中没有的数据查询1
select * from 巴枪记录表 t where t.扫描类型='到件' and t.扫描时间 >= to_date('30-4月-2007 12:00:00','DD-MON-YY HH24:MI:SS') and t.扫描时间 <= to_date('30-4月-2007 18:00:00','DD-MON-YY HH24:MI:SS') and t.录入部门='总部'查询2
select * from 巴枪记录表 t where t.扫描类型='发件' and t.扫描时间 >= to_date('30-4月-2007 12:00:00','DD-MON-YY HH24:MI:SS') and t.扫描时间 <= to_date('30-4月-2007 18:00:00','DD-MON-YY HH24:MI:SS') and t.录入部门='总部'
select * from 巴枪记录表 t where t.扫描类型='到件' and t.扫描时间 >= to_date('30-4月-2007 12:00:00','DD-MON-YY HH24:MI:SS') and t.扫描时间 <= to_date('30-4月-2007 18:00:00','DD-MON-YY HH24:MI:SS') and t.录入部门='总部'查询2
select * from 巴枪记录表 t where t.扫描类型='发件' and t.扫描时间 >= to_date('30-4月-2007 12:00:00','DD-MON-YY HH24:MI:SS') and t.扫描时间 <= to_date('30-4月-2007 18:00:00','DD-MON-YY HH24:MI:SS') and t.录入部门='总部'
and not exists(
select * from 巴枪记录表 t where t.扫描类型='发件' and t.扫描时间 >= to_date('30-4月-2007 12:00:00','DD-MON-YY HH24:MI:SS') and t.扫描时间 <= to_date('30-4月-2007 18:00:00','DD-MON-YY HH24:MI:SS') and t.录入部门='总部')
数据不多的话直接not exists就可以了
多的话就要优化下sql
用minus有结果吗?
看不出有问题的啊!
51放假,基本没人的.