select * from (select ROW_NUMBER () OVER (ORDER BY fat desc nulls last) AS xuhao,foodnum,foodname,fat from ek_food where isdel=0) food where foodnum = 'Ss192008'
涉及到的问题
1.排序时,字段值为null的会排在前面,导致数据不准确,解决办法 在order by后面增加 nulls last
2.给查询的结果增加序号 select ROW_NUMBER () OVER (ORDER BY fat desc nulls last) AS xuhao