sql – Oracle的最后一个下降顺序

前端之家收集整理的这篇文章主要介绍了sql – Oracle的最后一个下降顺序前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我的目标是以“DESCENDING”的顺序打印查询的结果.但是问题是,具有NULL值的行在列表的顶部.如何将空行放在底部,如果顺序是降序?
select mysubcat.subcat,mysubcat.subcatid as subcat_id,(select SUM(myad.PAGEVIEW) 
           from myad 
            where MYAD.CREATEDDATE between  '01-JUL-13 02.00.49.000000000 PM' and '13-JUL-13 02.00.49.000000000 PM'
            AND MYAD.status = 1 
            and  MYAD.mobileapp IS NULL
            and myad.subcatid = mysubcat.subcatid )as web_views 
from mysubcat 
order by web_views desc;

样品结果如此

SUBCAT_ID    WEB_VIEWS
Swimming Lessons                56        (null)    
Medical Services                17        (null)
Mobile Phones & Tablets         39        6519
Home Furnishing & Renovation   109        4519

顺序是降序,我只想把打印结果底部的空值为空,那么怎么办?

解决方法

您可以使用DESC NULLS LAST来实现.

这是Oracle的official documentation.

NULLS LAST

Specifies that NULL values should be returned after non-NULL values.

原文链接:https://www.f2er.com/mssql/82044.html

猜你在找的MsSQL相关文章