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

you are viewing a single comment's thread
view the rest of the comments
[–] 2 points 4 months 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

  • source