求一SQL语句。能实现按count(?)排序 在线等

爱我的人请呼吸 2009-04-01 03:52:13

  
有一语句

select a,b,count(b) as x from [T] where a='0'
group by a,b
having count(b)>=1
order by b

现在的要求不能按b排序。要按count(b)的结果进行排序

尝试了一下order by x不行。呵呵。

请各位兄弟指点一下怎么能实现按count(b)进行排序

先谢了
...全文
1970 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
y150988451 2009-11-17
  • 打赏
  • 举报
回复
学习 学习
gafinal 2009-10-20
  • 打赏
  • 举报
回复
我开看看
ly24860865 2009-04-01
  • 打赏
  • 举报
回复
select a,b,count(b) as x from [T] where a='0'
group by a,b
having count(b)>=1
order by count(b)

ks_reny 2009-04-01
  • 打赏
  • 举报
回复

select a,b,count(b) as x from [T] where a='0'
group by a,b
having count(b)>=1
order by count(b)

來晚了.
  • 打赏
  • 举报
回复



茅塞顿开

偶试了order by x不行居然就没去再尝试一下order by count(b)

罪过。。。


[Quote=引用 2 楼 playwarcraft 的回复:]
order by x 不行????
[/Quote]

回这位大哥。我这里用order by x会提示“至少有一个参数没有指定值"

但是用order by count(b)就可以


再次感谢楼上几位大哥

给分好为难。平均给分吧。再次感谢
lgx0914 2009-04-01
  • 打赏
  • 举报
回复
?

select a,b,count(b) as x from [T] where a='0'
group by a,b
having count(b)>=1
order by count(b)
sdhdy 2009-04-01
  • 打赏
  • 举报
回复
select a,b,count(b) as x from [T] where a='0' 
group by a,b
having count(b)>=1 order by x
sdhdy 2009-04-01
  • 打赏
  • 举报
回复
select * from (select a,b,count(b) as x from [T] where a='0' 
group by a,b
having count(b)>=1) c order by x
playwarcraft 2009-04-01
  • 打赏
  • 举报
回复
order by x 不行????
liangCK 2009-04-01
  • 打赏
  • 举报
回复
ORDER BY count(b)

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧