No video

Find nth highest salary in sql server | sql query to find 2nd, 3rd highest salary

  Рет қаралды 48,962

Questpond

Questpond

Күн бұрын

Пікірлер: 32
@questpondvideos
@questpondvideos 2 жыл бұрын
20+ SQL Server Interview Questions : kzfaq.info/get/bejne/iauUdKlp0rmvg2g.html Software Architecture Interview Questions : kzfaq.info/get/bejne/d9qEmsaTsbXVfYE.html SQL Step by Step - kzfaq.info/get/bejne/q62cmbNq1J3PnY0.html SQL Server Joins : kzfaq.info/get/bejne/gbqmjKt209ranmw.html 20 MSBI Interview Questions : kzfaq.info/get/bejne/hN2Ppqt2sNSzhXk.html 10+ Power BI Interview Questions : kzfaq.info/get/bejne/edWqlpyIs6i2pGg.html Angular Step by Step Tutorial for Beginners : kzfaq.info/get/bejne/Y5-Glrposqioo2w.html 25 Angular Interview Questions : kzfaq.info/get/bejne/Y9CVotx1r6rXg4E.html 35 Important JavaScript Interview Questions : kzfaq.info/get/bejne/kMhkl7OanKmlfok.html 30 Important C# Interview Questions : kzfaq.info/get/bejne/eLGpoahztdfNeYE.html 25+ OOPS Interview Questions : kzfaq.info/get/bejne/q59pqqSgp9CopoU.html 25 Important ASP.NET Interview Questions : kzfaq.info/get/bejne/pr6dgMeer7unYJs.html 20 MySQL Interview Questions : kzfaq.info/get/bejne/b86WnaZep9a9YmQ.html 20 PHP Interview Questions : kzfaq.info/get/bejne/Z8iggbaq07vWnGw.html 5 MSBI Interview Questions : kzfaq.info/get/bejne/a6toZJiSvafbiYU.html
@keyurpanchal6452
@keyurpanchal6452 2 жыл бұрын
Select * from employee E1 where n-1 = (select count(*) from employee E2 where E1.Salary < E2.Salary) n = nth highest salary.
@harishshah8967
@harishshah8967 Жыл бұрын
Thank you very much this was the easiest solution i could find on internet i'm glad i came across your comment
@angelanaya8037
@angelanaya8037 Жыл бұрын
Never got such a simple explanation, Thank you very much sir
@SowndaryaS-ue7su
@SowndaryaS-ue7su 15 күн бұрын
Really well explained topics.. I got new interest in learning .. Thank you..
@wishujadhav
@wishujadhav 2 жыл бұрын
One of cross question asked by interviewer is, if more than one records having same 2nd higest salary, query in video gives only one record
@ryuzaki6865
@ryuzaki6865 2 жыл бұрын
Write a CTE (Common Table Expression) using DENSE_RANK() function.
@jyotirmoymaschatak2599
@jyotirmoymaschatak2599 2 жыл бұрын
I was asked this question yesterday in the interview.
@hrudayaranjanmohanty2689
@hrudayaranjanmohanty2689 2 жыл бұрын
So Nicely Explained sir..
@Shanmugamanickavel
@Shanmugamanickavel Жыл бұрын
Your training is excellent
@AlokChandraShahi
@AlokChandraShahi Ай бұрын
Declare @N Int =2 Select EmployeeSalary From ( Select Dense_Rank() Over (Order By EmployeeSalary) SNo, EmployeeSalary From TblEmployee) temp Where SNo =@N
@tejap7308
@tejap7308 2 жыл бұрын
Very helpful. Thank you very much sir
@sk_ashadul_islam
@sk_ashadul_islam 11 ай бұрын
Instead of row_number we can use dense_rank , bcoz if the table has duplicate 2nd highest salary and we nned to show both then it is not possible by row_number()
@dileepkumars
@dileepkumars 2 жыл бұрын
Fetch 1 offset n order by employeesalary should be the simplest way i think
@questpondvideos
@questpondvideos 2 жыл бұрын
Definitely a simple solution, but offset and limit is not ANSI SQL.From TSQL point of view its the simplest solution.
@varshadeore154
@varshadeore154 Жыл бұрын
Very nice explanation as asual
@salarsayyad5522
@salarsayyad5522 Жыл бұрын
Bunch of thanks sir.🙏😊
@remmykesh5533
@remmykesh5533 2 жыл бұрын
very helpful, thank you.
@suyashyadav6531
@suyashyadav6531 2 жыл бұрын
Great content as always.
@OggVorbis69
@OggVorbis69 2 жыл бұрын
The video demonstrates well the idea but probably is not going to work if there are duplicated salaries in the table. To solve this group by the salary in the sub query. However using rank will be a better solution selecting the nth rank as the nth top salary. In places where top or rank is not available an insert into temp table with autooncrement first column and sequential select the nth row from it will do too.
@questpondvideos
@questpondvideos 2 жыл бұрын
It surely works for duplicate , top secures it. Temp table would be a bad solution.
@saravanan.b
@saravanan.b 2 жыл бұрын
In Oracle how can I find the same result. Top command will not work right?
@pulkitjain4476
@pulkitjain4476 2 жыл бұрын
use rank and select where rank = 1
@questpondvideos
@questpondvideos 2 жыл бұрын
Rank is simple , LIMIT will more simple ,but these are TSQL. Will not work for other DB. In todays date with EF and Code first ANSI SQL has become more important. Thanks.
@sk_ashadul_islam
@sk_ashadul_islam 11 ай бұрын
But if it is for 2nd highest salary and the table has duplicate top highest salary , Rank() will not give you exact results
@stewiegriffin6503
@stewiegriffin6503 2 жыл бұрын
the problem for me is that I don't want to get a job, because then I have to go to work... So I prefer to go unprepared to the interview, and then blame the company for xenofobia. High 5 !
@kushagrasharma4061
@kushagrasharma4061 2 жыл бұрын
I have paid to join the channel but still I am unable to get access to videos.
@questpondvideos
@questpondvideos 2 жыл бұрын
Just make sure you are accessing membership videos from same google account from where you have made the purchase or you can contact youtube help center if you do not get the access.
@bitsdiaries
@bitsdiaries Жыл бұрын
Did u get the access? Do u recommend it?
@dinkarjha4500
@dinkarjha4500 Жыл бұрын
In PostgreSQL how to achieve?
@poonamsify4276
@poonamsify4276 6 ай бұрын
Thank you so much Sir
@sourabhthorat9550
@sourabhthorat9550 2 жыл бұрын
CREATE FUNCTION getNthHighestSalary(@N INT) RETURNS INT AS BEGIN RETURN ( select distinct salary from Employee order by salary desc OFFSET @N-1 ROWS FETCH NEXT 1 ROWS ONLY ); END
SQL Server interview question :- Explain RowNumber,Partition,Rank and DenseRank ?
10:50
.NET Interview Preparation videos
Рет қаралды 526 М.
SPONGEBOB POWER-UPS IN BRAWL STARS!!!
08:35
Brawl Stars
Рет қаралды 23 МЛН
拉了好大一坨#斗罗大陆#唐三小舞#小丑
00:11
超凡蜘蛛
Рет қаралды 14 МЛН
Пройди игру и получи 5 чупа-чупсов (2024)
00:49
Екатерина Ковалева
Рет қаралды 4,4 МЛН
这三姐弟太会藏了!#小丑#天使#路飞#家庭#搞笑
00:24
家庭搞笑日记
Рет қаралды 103 МЛН
The 25 SQL Questions You MUST Know for Data Analyst Interviews
32:47
KSR Datavizon
Рет қаралды 215 М.
Top 25 SQL Server Interview Questions - .NET C#
1:06:04
Interview Happy
Рет қаралды 107 М.
SPONGEBOB POWER-UPS IN BRAWL STARS!!!
08:35
Brawl Stars
Рет қаралды 23 МЛН