当前位置: 代码迷 >> Sql Server >> 查询数据库中表字段 字段按由大到小排序 求解决办法!
  详细解决方案

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

热度:71   发布时间:2016-04-27 13:41:38.0
查询数据库中表字段 字段按由大到小排序 求解决方法!!!!
查询语句
SQL code
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

上面的语句怎么改,求大虾指点!!!!!!!!!!!

------解决方案--------------------
SQL code
order by stateID  desc,stepID
------解决方案--------------------
SQL code
select stateID,stepID from pro1 where code=217 group by stateid,stepID order by stateid desc,stepID desc
------解决方案--------------------
探讨
SQL code

order by stateID desc,stepID



desc 换换位置就可以了

------解决方案--------------------
SQL code
select stateID,stepID from pro1 where code=217 group by stateid,stepID order by stateid desc,stepID
  相关解决方案