Hi, In first question while finding the top 3 employees within each department, dense_rank() would be appropriate one because it will handle tie values without skipping the ranking rather than row_number IMO. Thank you for the constant motivation through SQL Questions ! Looking for more ...
On the contrary, using dense_rank may give us more than 3 values (if there are ties), rather we only need to find top 3 highest paid employees (3 rows), row_number will always ensure that we get only 3 rows in the result set.
Hi,
In first question while finding the top 3 employees within each department, dense_rank() would be appropriate one because it will handle tie values without skipping the ranking rather than row_number IMO.
Thank you for the constant motivation through SQL Questions ! Looking for more ...
Yes, definitely if the interviewer asked us to provide the same rank for duplicate values.
Thanks for mentioning it 👍
On the contrary, using dense_rank may give us more than 3 values (if there are ties), rather we only need to find top 3 highest paid employees (3 rows), row_number will always ensure that we get only 3 rows in the result set.