查询数据库中表字段 字段按由大到小排序 求解决方法!!!!

Dotar 2012-03-27 09:35:24
查询语句
select 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

上面的语句怎么改,求大虾指点!!!!!!!!!!!
...全文
273 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Dotar 2012-03-27
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 beirut 的回复:]
引用 3 楼 hikor 的回复:

引用 1 楼 beirut 的回复:
SQL code

order by stateID desc,stepID



desc 换换位置就可以了


正解


错了, 要两个dese


SQL code

order by stateID desc,stepID dese
[/Quote]


嗯嗯 对了 散分。。。
Dotar 2012-03-27
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 czp98168 的回复:]
SQL code

select stateID,stepID from pro1 where code=217 group by stateid,stepID order by stateid desc,stepID desc
[/Quote]
这个是对的。。。。
黄_瓜 2012-03-27
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 hikor 的回复:]

引用 1 楼 beirut 的回复:
SQL code

order by stateID desc,stepID



desc 换换位置就可以了


正解
[/Quote]

错了, 要两个dese

order by stateID  desc,stepID dese

勿勿 2012-03-27
  • 打赏
  • 举报
回复
select stateID,stepID from pro1 where code=217
group by stateid,stepID
order by stateid desc
,stepID
Hikor 2012-03-27
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 beirut 的回复:]
SQL code

order by stateID desc,stepID



desc 换换位置就可以了
[/Quote]

正解
CZP98168 2012-03-27
  • 打赏
  • 举报
回复
select stateID,stepID from pro1 where code=217 group by stateid,stepID order by stateid desc,stepID desc
黄_瓜 2012-03-27
  • 打赏
  • 举报
回复
order by stateID  desc,stepID



desc 换换位置就可以了

34,594

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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