Skip to content
Advertisement

Trying to utilize a window function instead of this script

I’m trying to improve my query for this topic at hand. I’m trying to find the top 5 and bottom 5 growth rates per state from 2020 to 2021 in my org. The table has the columns as specified: orderid, orderdate, totaldue, state, etc. (these are probably the most important columns). This is the query I created so far, while it works I think it would be more efficient if I was able to implement a window function instead.

Advertisement

Answer

You could use DENSE_RANK here:

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