where not exists(select top 49 * from a as a2 where a1.ID=a2.ID)
sqlserver2000中:select top 50 * from 表 where id not in (select top 29 id from 表)
sqlserver2005中:
select top 50 * from 表 except select top 29 * from 表
Oracle中:
select * from 表 whre rownum<=50 minus select * from 表 where rownum<=29
mysql中:
select * from 表 limit 30,50
select name,count(*) as 'Count' from a group by name where cust_no is not nullunion
select name,0 as 'Count' from a group by name where cust_no is null
分开查再合并就是了 先查非0的 用count 和 group by
再查是0的 然后用union合并就是了
因为不确定cust_no为空的时候设置的是什么数据类型 这里的判断条件我用的是is null 根据实际可能要改下
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)