Тёмный

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

Questpond
Подписаться 214 тыс.
Просмотров 49 тыс.
50% 1

Опубликовано:

 

5 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 33   
@questpondvideos
@questpondvideos 2 года назад
20+ SQL Server Interview Questions : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-SEdAF8mSKS4.html Software Architecture Interview Questions : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-AtTgcbLOqMM.html SQL Step by Step - ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-uGlfP9o7kmY.html SQL Server Joins : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-KTvYHEntvn8.html 20 MSBI Interview Questions : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Nw_sHEKnOUE.html 10+ Power BI Interview Questions : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Cozc9WNBRt4.html Angular Step by Step Tutorial for Beginners : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE--9VcW7MBDs8.html 25 Angular Interview Questions : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE--jeoyDJDsSM.html 35 Important JavaScript Interview Questions : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Zb4dPi7CANU.html 30 Important C# Interview Questions : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-BKynEBPqiIM.html 25+ OOPS Interview Questions : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-u99wAoBjDvQ.html 25 Important ASP.NET Interview Questions : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-pXmMdmJUC0g.html 20 MySQL Interview Questions : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-9hfjC-BpY20.html 20 PHP Interview Questions : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-1bpNSynUrl8.html 5 MSBI Interview Questions : ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-5E815aXAwYQ.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 Месяц назад
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.
@AlokChandraShahi
@AlokChandraShahi 2 месяца назад
Declare @N Int =2 Select EmployeeSalary From ( Select Dense_Rank() Over (Order By EmployeeSalary) SNo, EmployeeSalary From TblEmployee) temp Where SNo =@N
@sakshipare9180
@sakshipare9180 18 дней назад
Thanks for all the knowledge that you have shared and sharing with youtube family. Your videos are helpful for 1000s of people I am sure. I was looking for sql interview question's part 2,3 which you have mentioned in part 1 But I couldn't see link for that. Could you please share with us?
@tejap7308
@tejap7308 2 года назад
Very helpful. Thank you very much sir
@sk_ashadul_islam
@sk_ashadul_islam Год назад
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()
@hrudayaranjanmohanty2689
@hrudayaranjanmohanty2689 2 года назад
So Nicely Explained sir..
@Shanmugamanickavel
@Shanmugamanickavel Год назад
Your training is excellent
@salarsayyad5522
@salarsayyad5522 Год назад
Bunch of thanks sir.🙏😊
@remmykesh5533
@remmykesh5533 2 года назад
very helpful, thank you.
@varshadeore154
@varshadeore154 Год назад
Very nice explanation as asual
@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.
@saravanan.b
@saravanan.b 2 года назад
In Oracle how can I find the same result. Top command will not work right?
@suyashyadav6531
@suyashyadav6531 2 года назад
Great content as always.
@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?
@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 Год назад
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 !
@poonamsify4276
@poonamsify4276 7 месяцев назад
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
@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.
Далее
This mother's baby is too unreliable.
00:13
Просмотров 16 млн
LOLLIPOP-SCHUTZ-GADGET 🍭 DAS BRAUCHST DU!
00:28
Просмотров 12 млн
Мои РОДИТЕЛИ - БОТАНЫ !
31:36
Просмотров 487 тыс.
Part 1   How to find nth highest salary in sql
11:45
Просмотров 1,9 млн