您的位置:首页 > 数据库

一个统计的sql语句

2007-04-27 15:06 423 查看
请用SQL语句实现:从TestDB数据表中查询出所有月份的发生额都比

101科目相应月份的发生额高的科目。请注意:TestDB中有很多科目,

每个科目都有1-12月份的发生额。
id: 科目代码
months:发生

额月份,
money:发生额
数据库名:JcyAudit

select distinct id from testdb t where not exists

( select t1.*, t2.* from testdb t1 ,testdb t2 where t2.id = 101 and

t1.months = t2.months and t1.id = t.id and t1.money <=

t2.money);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: