RANK() and DENSE_RANK() are SQL window functions used to assign ranks to rows within a partition. RANK() leaves gaps in ranking values if there are ties while DENSE_RANK() does not. They are useful for tasks such as identifying top performers and creating ordered lists. The choice between them depends on whether you need a ranking sequence with gaps or a continuous sequence.

7m read timeFrom code.likeagirl.io
Post cover image
Table of contents
Be like a kid and ask whyIt’s ShowtimePretty easy to spot the differenceWhen to use what?Conclusion

Sort: