DEV Community

shubham mishra
shubham mishra

Posted on • Originally published at developerindian.com

1

SQL query to find second highest salary using dens_rank function ?

This is Question is most use full in Sql interview ,Below is Employee Table and we are going to write Sql Query using Dense rank function that is windowing function :

Name age salary department
shubham mishra 31 20000 computer
rahul kumar 20 30000 electric

select Name , age , salary   , 
dens_rank  over (partition by  department    order by  salary desc ) as rank 
from 
Employee 
where rank =2
Enter fullscreen mode Exit fullscreen mode

This Solution is provided by Shubham mishra This article is contributed by Developer Indian team. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. Also folllow our instagram , linkedIn , Facebook , twiter account for more

Top comments (0)

The best way to debug slow web pages cover image

The best way to debug slow web pages

Tools like Page Speed Insights and Google Lighthouse are great for providing advice for front end performance issues. But what these tools can’t do, is evaluate performance across your entire stack of distributed services and applications.

Watch video

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay