mssql2000判断全部列大于等于某列值
mssql2000判断全部列大于等于某列值
billid,qty,exeqty
1001, 300, 200
1001, 350, 350
1001, 700 ,750
1001, 600, 700
1001, 350, 350
1001, 700 ,699 ----这是没有超或等于699
要求结果:判断同一BILLID,当exeqty全部都大于或等于qty的数据
billid,qty,exeqty,
1001, 300, 200
1001, 350, 350
1001, 700 ,750
[解决办法]
select BILLID, qty, exeqty from tab a inner join tab b on a.BILLID=b.BILLID where a.exeqty>b.qty--你需要的结果应该是/*billid qty exeqty1001 600 7001001 350 3501001 700 750*/
[解决办法]
select * from tb a where a.exeqty>=a.qty and not exist(select 1 from tb b where a.billid=b=billid and b.exeqty<b.qty )