Oracle: Display row number with 'order by' clause

前端 未结 4 1115
独厮守ぢ
独厮守ぢ 2021-02-02 17:14

I wonder how could i print a row number for sql statement where is using order. Currently i tried ROWNUM but as i understand it works only for unsorted result set.

4条回答
  •  粉色の甜心
    2021-02-02 17:54

    rownum is applied before ordering, so you have to rewrite your query like this: select rownum, xxx.* from ( SELECT a.lg_id, a.full_name, a.sort_order FROM activity_type_lang a where a.lg_id = 'en' order by a.full_name ) xxx;

提交回复
热议问题