Tuesday, 15 July 2025

Window Functions in SQL

 Problem

I need to rank the rows based on serial number and the serial numbers should be ranked based on the latest inspection date. I have duplicate serial numbers in my data set. How to Achieve.


Solution :

you can use any of the below method to achieve without using Partition

SQL Query - Dense_Rank() over (order by InspectionDate desc, SerialNumber) as row_num

No comments:

Post a Comment