Need to perform ORDER by Twice

大憨熊 提交于 2019-12-10 04:17:01

问题


I want to sort according to date first and then if date is similar then according to id..How to do that in Informix/HSQL query?


回答1:


SELECT FIELD1, FIELD2 FROM TABLE ORDER BY FIELD1 ASC, FIELD2 ASC

A good tutorial on this SQL ORDER BY




回答2:


Try this(adjusted to your needs):

SELECT * FROM table ORDER BY datecol ASC, id ASC



回答3:


This should work:

SELECT * FROM Table
ORDER BY date, id;



回答4:


Does

[rest of query] order by date, id

work?




回答5:


select * from (select * from tablename order by col1) order by col2



来源:https://stackoverflow.com/questions/8532599/need-to-perform-order-by-twice

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!