Sql Order by on multiple column

后端 未结 4 1240
小鲜肉
小鲜肉 2021-02-13 06:10

I\'ve the below result

VendorName | IncidentID | IncidentStatus | IncidentDate
-------------------------------------------------------
XYZ        | 100        |         


        
4条回答
  •  日久生厌
    2021-02-13 06:33

    select vendorname, incidentid, incidentstatus, incidentdate, max(incidentdate) 
    over (partition by vendorname order by incidentdate desc) max_incidentdate
    from t1 order by max_incidentdate desc, incidentdate desc
    

提交回复
热议问题