关于查询语句按两个字段排序问题,不知道可不可以,求大虾指点!!!!!

Dotar 2012-03-27 09:40:01
查询语句
SQL codeselect stateID,stepID from pro1 where code=217 group by stateid,stepID order by stateid,stepID desc
查出来的结果是
stateID stepID:
1 2
1 1
1 0
2 1
2 0
我想要的结果是:
stateID stepID
2 1
2 0
1 2
1 1
1 0

上面的语句怎么改,求大虾指点!!!!!!!!!!!
...全文
86 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
chen_ya_ping 2012-03-27
  • 打赏
  • 举报
回复
stateID stepID
2 1
2 0
1 2
1 1
1 0

order by stateid desc ,stepID DESC
Dotar 2012-03-27
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 chinajiyong 的回复:]
该是stateid 降序
select stateID,stepID from pro1 where code=217 group by stateid,stepID order by stateid desc,stepID desc
[/Quote]


正解!!!!!!
Dotar 2012-03-27
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 lisweden 的回复:]
order by stateid ASC,stepID DESC
[/Quote]

你这样错了
!!!
lisweden 2012-03-27
  • 打赏
  • 举报
回复
order by stateid ASC,stepID DESC
bdmh 2012-03-27
  • 打赏
  • 举报
回复
stateid desc,stepID desc 两个字段都降序排列

EnForGrass 2012-03-27
  • 打赏
  • 举报
回复
该是stateid 降序
select stateID,stepID from pro1 where code=217 group by stateid,stepID order by stateid desc,stepID desc
EnForGrass 2012-03-27
  • 打赏
  • 举报
回复
select stateID,stepID from pro1 where code=217 group by stateid,stepID order by stateid asc,stepID desc
Ny-6000 2012-03-27
  • 打赏
  • 举报
回复
order by stateid DESC ,stepID desc

冰镇宝贝321 2012-03-27
  • 打赏
  • 举报
回复
select stateID,stepID from pro1 where code=217 group by stateid,stepID order by stepID,stateid desc
试试看
冰镇宝贝321 2012-03-27
  • 打赏
  • 举报
回复
额 不好意思 看错了



可以得出结果的
冰镇宝贝321 2012-03-27
  • 打赏
  • 举报
回复
2 1
2 0
1 2
1 1
1 0

搞什么 前2个是按第一个数字大小排序 后面三个 就按第二个数字大小排列

完全没规律啊

62,267

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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