Hacker News new | ask | show | jobs
by redhale 1409 days ago
Forget HAVING -- in my opinion RANK is the most useful SQL function that barely anyone knows about. Has gotten me out of more sticky query issues than I can count.
2 comments

The entire family of Windowing Functions which are mostly ubiquitous on all modern SQL seem to be glossed over by most.
RANK is a good example of a useful less known window function. Please also consider dense_rank and row_number. All 3 have their advantages and disadvantages... (Rank leaves holes after rows with the same order, dense_rank gives consecutive numbers, row_number just numbers the rows.)