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 :(

  • verstra@programming.dev
    link
    fedilink
    arrow-up
    2
    ·
    3 days ago

    Think of them as operating on the whole column at once.

    For example LAG would be like selecting a whole column in excel and copy pasting it one row down