SQL Query to Find Nth Highest Salary Using Dense Rank Function
ฝัง
- เผยแพร่เมื่อ 9 มิ.ย. 2022
- Hi, In this video we've discussed SQL query for nth highest salary using dense rank function. This is an Important SQL Interview question.
✨Work related mails can be sent on work.sadiasiddiqui@gmail.com
✨If you appreciate my work and would like to donate to support our channel, you can do so here : paypal.me/sadia1702
✨Please like, share, subscribe and comment down. It would make my day :)
Thank you, have a nice day!
Do you have any suggestion for SQL course to be taken for beginners/intermediate/advanced level?
Excellent explanation.... Thanks
Ma'am you didn't give the definition or working of (DENSE_rank). Please elaborate it.
Sukriyaa mam. You solved my big question❤️❤️
Define a variable with Varchar 1000 and assign
the value ‘IND-India,JPN-Japan,US-United States’
This string can be of any length.
Write a dynamic query to insert data in a table with
two columns column 1 should have Country Short
Form and column 2 should have Country Full Form.
Output should be: -
Short Form Full Form
IND India
JPN Japan
US United States
Ma'am Please solve this question with explanation
Saadia appi you are great ❤️❤️❤️
Thank you mam
This can be said another way of finding second highest salary, video having 3 methods : max,limit,top right ?
Does rank function gives the same result?
If we have duplicates ...
Then how can we write query...?
u can use the row number then.
Mam please use max function
What if there's a duplicate salary?
It will give all records for that salary , so all records where Rn=2 will be displayed.
That is right, it covers all records that meet the condition specified
Here we are using Dense_rank() function so if we have duplicate salaries then Dense_rank() will assign same rank to the same salaries. It wouldn't assign continuous rank for the same salary. Hope you understood
Mam please use the max function instead of dense rank
Why did you use "in line" sub query
Was wondering the same thing. Can the filter not be applied directly to the dense rank query?
@@mummz3371 yeah why can't we use directly qualify filter.. rather than where clause
Firstly, we are applying dense rank function and creating a derived table in which dense rank function gives a rank to each salary in desc order
Then, we give alias to inner query and selecting from that inline query.
@@ruqaiyamuskaan9722why again need of where clause...we can directly get through qualify clause
@@kranthikumar6043 basically, we need to give rank to each salary then put a rank
Here where clause is used to set a rank