SQL Server Data Ranking

Source: Internet
Author: User

List of city rankings

SELECTC.sheng, M.city, RANK () Over(ORDER  by round(avg(cast(Indexs as float)),3)) aspx,round(avg(cast(PM25 as float)),0) PM25,round(avg(cast(PM10 as float)),0) PM10,round(avg(cast(Co as float)),3) CO,round(avg(cast(NO2 as float)),0) NO2,round(avg(cast(SO2 as float)),0) SO2,round(avg(cast(O3_8 as float)),0) O3_8,round(avg(cast(Indexs as float)),3) Indexs,round(avg(cast(AQI as float)),0) AQI fromMonitor_city_hour m,cd_city CwhereM.city=C.city and          datetime='2017-03-04 12:00:00'  andAQi!=0  andPm25!=0  andPm25 is  not NULL          Group  byc.sheng,m.cityOrder  byIndexs

The ranking curve of a city for some time

 SelectFDate Time,px,aqi from(        SELECTFdate,city,rank () Over(Partition byFDateORDER  byAQi asPx,aqi fromMonitor_city_daywhereAQi!=0  andPm25!=0  andPm25 is  not NULL           and cast(FDate as datetime)>=cast('2017-02-01'  as datetime) and          cast(FDate as datetime)<=cast('2017-03-05'  as datetime)) awhereCity='Beijing'          Order  by cast(FDate as datetime)

SQL Server Data Ranking

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.