I have been struggling to understand the window functions. I understand its use case like when you want to rank countries population per continent however the syntax is so weird it doesn’t make any sense what actually happening

How does the sql server process this? does it run on every row? is there any benefit of using it over subquery?

sorry if this question is too dumb :(

  • Feyd@programming.dev
    link
    fedilink
    arrow-up
    10
    ·
    4 days ago

    The main thing is that group by gives you a smaller number of rows than the input, collapsing the data from individual rows into the group rows in the output, while a window function does not change the number of rows - it just allows you to use data from other rows for calculations in each output row