SQL Trick: row_number() is to SELECT what dense_rank() is to SELECT DISTINCT

The SQL:2003┬ástandard ranking functions are awesome companions and useful tools every now and then. The ones that are supported in almost all databases are: ROW_NUMBER(): This one generates a new row number for every row, regardless of duplicates within a partition. RANK(): This one generates a new row number for every distinct row, leaving gaps … Continue reading SQL Trick: row_number() is to SELECT what dense_rank() is to SELECT DISTINCT