Skip to content
Advertisement

Dense_Rank does not work as it is expected

I’m creating a query where I need to get the ranking depending on how many are duplicated in the column “MacAddress”(amount) in the table MacsUsers, this is the data: enter image description here

this is my SQL query:

I think I’m doing well with the DENSE_RANK function but it does not work as it is expected, any possible solution? thanks advance

Advertisement

Answer

Your DENSE_RANK window function should apply ordering on the “Quantity” field instead of the “MacAddress” field. In order to apply a window function on an aggregated field, you need to have a subquery as follows.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement