Re:Having, a less understood SQL clause
by redhale on Saturday August 06, 2022 @07:09AM
(#32366993)
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.
[ Parent
| on HN ]
Re:Having, a less understood SQL clause
by jupiter909 on Saturday August 06, 2022 @11:42AM
(#32369062)
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.)