oracle里面的minus,换到sql2000里面是什么?

来源:百度知道 编辑:UC知道 时间:2024/06/24 10:18:18
举例:
select count(*) as “次数”
from ( (select callid from 日志表
where 查询条件1
group by callid
minus (select id from 日志表 where
查询条件2
) );

SqlServer2005中开始使用 【execpt】 实现和 oracle中 【minus】一样的功能,但是SqlServer2000中并不支持 【execpt】只能用【not exists】实现。

select count(*) as “次数”
from (
(select callid from 日志表 where 查询条件1 group by callid
not exists
(select id from 日志表 where 查询条件2 ))t;

值得注意的是SqlServer中使用子查询的时候必须要给子查询起名字,就像上面的【t】,否则会报错。

---
以上,希望对你有所帮助。

select count(distinct myID ) as “次数”
from (
(select callid as myID from 日志表
where 查询条件1
group by callid
union all
select id as myID from 日志表 where 查询条件2
)
) as myTable

sql server是不支持minus的!

可以考虑使用not exist