sql查询一列条件是查询出来的两列 100
selectb,sum(c)asdfromAAwhereb<>'98760000'andb<>''andABCbetween'2015-09-22'and'2015-11...
select b,sum(c) as d from AA where b<>'98760000' and b<>''
and ABC between '2015-09-22' and '2015-11-22 23:59:59' group by b order by d
DESC,b
上面语句查询出来的结果,我挑选排名前2000作为 SELECT * FROM QWE 的取的范围,请问应该怎么写?
谢谢 展开
and ABC between '2015-09-22' and '2015-11-22 23:59:59' group by b order by d
DESC,b
上面语句查询出来的结果,我挑选排名前2000作为 SELECT * FROM QWE 的取的范围,请问应该怎么写?
谢谢 展开
展开全部
select 后加个TOP 2000 ,再把这一条,嵌套到QWE表的WHERE条件语句后,用括号。
追问
能详细点么?大神
追答
select * from qwe where b = (
select top 2000 b,sum(c) as d from AA where b<>'98760000' and b<>''
and ABC between '2015-09-22' and '2015-11-22 23:59:59' group by b order by d
DESC,b )
以这种形式,具体情况你再修改,测试看看
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询