Skip to content
Advertisement

Get difference from top ranked item

I’m using the following query to rank items, but I need it to also show the difference between the item and the top ranked item (The top ranked item will show the difference between it and the 2nd ranked item.), like so:

How do I create the DiffTop column?

Advertisement

Answer

You can use window functions for this as well:

The top ranked value is the one with maximum SF.

To handle the top ranked item:

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