求助一个sql的命令

[复制链接]
查看11 | 回复3 | 2008-1-21 16:50:24 | 显示全部楼层 |阅读模式
select count(t.a) fromt
where t.a not in
(select t1.a fromt1,t2where t1.s <= t2.s and t1.a= t2.a)
改为 not exise 怎么改? 我改的总是出错
很多采用exise 的例子是 子查询只有一个表的,我的是2个表,怎么改,运行都不正确
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
select count(t.a) from t
wherenot exists (
select 1 from t1, t2 where t1.s <= t2.s and t1.a = t2.a and t1.a = t.a
);
这样么?
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
我用过,这样的结果不对
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
select count(t.a) from t
where not exists (
select* from t1, t2 where t1.s <= t2.s and t1.a = t2.a and t1.a = t.a
);
可以了,可能是我写错了一个参数,谢谢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行