SQL语句order by两个字段同时排序:
参考文章:https://blog.csdn.net/sun1042445773/article/details/50352159
select name,ord,parent_id from EMR_CATALOG
where state=1 and parent_id=15
order by ord asc,id asc
效果为:结果为ord升序排序,相同的ord之后的id再升序排序;
ORA-01791:不是SELECTed表达式:
参考文章:https://blog.csdn.net/blueling51/article/details/7571935
如果按照之前的命令加入distinct去重时,多个字段排序时会报错,解决办法是在distinct字段中加入排序的字段:
select distinct name,ord,parent_id,id from EMR_CATALOG
where state=1 and parent_id=15
order by ord asc,id asc