SQL Interview Question - Find Nth Highest Salary | LeetCode

  Рет қаралды 37,277

Sumit Mittal

Sumit Mittal

Күн бұрын

To enhance your career as a Cloud Data Engineer, Check trendytech.in/?src=youtube&su... for curated courses developed by me.
I have trained over 20,000+ professionals in the field of Data Engineering in the last 5 years.
SQL Interview Question - Find Nth Highest Salary | LeetCode
Do Like, Comment & Subscribe ..
𝗝𝗼𝗶𝗻 𝗺𝗲 𝗼𝗻 𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:🔥
🔅Sumit LinkedIn - / bigdatabysumit
🔅Sumit Instagram - / bigdatabysumit
In this video, we will solve SQL question on LeetCode. LeetCode is an excellent platform for practicing SQL Queries. The SQL Questions on LeetCode are framed pretty similar to how they are asked on SQL Interviews hence solving SQL questions on LeetCode can give you a good hands on experience on solving real world SQL questions.
Find the nth highest Salary is a very frequently asked SQL Interview question.
#SQL #RDBMS #database #bigdata #dataengineering

Пікірлер: 28
@sumitmittal07
@sumitmittal07 Жыл бұрын
Checkout the Big Data course details here: trendytech.in/?referrer=youtube_lc2
@ashishranjan4387
@ashishranjan4387 3 ай бұрын
For a non IT data analyst aspirant like me, this was a wonderful session. Each and every thing explained concept is clear
@pranutabedru4395
@pranutabedru4395 2 жыл бұрын
Thank you Sir for clearing the concept
@sayantansarbadhikary6917
@sayantansarbadhikary6917 Ай бұрын
Very well explained sir.. The way you explain things ans then give the solution actually prepares our way to think logically about the problems Thanks a lot. Please come up with more learnings
@arunsundar3739
@arunsundar3739 3 ай бұрын
learnt new concepts : isNull & offset, also how to approach a problem in multiple ways, thank you very much sir :)
@rawatbobby8883
@rawatbobby8883 Ай бұрын
Thank you thank you so much, i understand from you rvideo from one go, really amazing sir you are, thanks a lot, and keep moving in this era 😎❤
@mallikarjunpatil7553
@mallikarjunpatil7553 2 жыл бұрын
Waiting for next Video
@arunprasadhsj
@arunprasadhsj 2 жыл бұрын
Thank you :)
@messi_codes
@messi_codes 2 жыл бұрын
thanks
@MAYANKKUMAR-kg5kc
@MAYANKKUMAR-kg5kc 2 жыл бұрын
Hello sir, Can you please share tips to solve this problem statement ? There's a grocery store sales transaction table with columns Tnx ID, customer ID, product ID, Date of Tnx, quantity, price. Every sales transaction that happens at the store, gets stored in this table. The store also has a customers table with columns Customer ID, Customer Name, Age, Gender, and Locality. Write an SQL query to find the name and locality of the customer who purchased the highest number of items in the month of Oct’21.
@ashitosh501
@ashitosh501 2 жыл бұрын
Make video on MySQL performance tuning
@arunavabiswas9177
@arunavabiswas9177 Жыл бұрын
Thanks for your videos.They are quite good. I just feel I the offset solution will not work. As you don't know beforehand the number of distinct values that will return and dependending on that you have to provide the offset count.
@mallikarjunpatil7553
@mallikarjunpatil7553 2 жыл бұрын
Thanks for explaining multiple approaches. it seems IFNULL() not working in oracle
@Anonymous_it_is
@Anonymous_it_is 2 жыл бұрын
you can use 'NVL' for oracle DB, it works exactly same
@sukanyaiyer2671
@sukanyaiyer2671 2 жыл бұрын
Can you give your solution. ..sql query txt file as well.. Or can post it on your Github and share the link
@SahilGupta-gy5ey
@SahilGupta-gy5ey 2 жыл бұрын
Advance Version - Find n ( eg 10 ) highest salary without order by clause..
@ayushsen293
@ayushsen293 2 жыл бұрын
Thanks sir.. approaches are really interesting... but i think oracle dont have IFNULL feature .. not sure how to get null with 3rd approach
@Anonymous_it_is
@Anonymous_it_is 2 жыл бұрын
you can use 'NVL' for oracle
@ashishranjan4387
@ashishranjan4387 4 ай бұрын
Instead of limit 1 offset 1, can not we do limit 1,1
@mohammedasif4349
@mohammedasif4349 Жыл бұрын
In LC Ques no-177 where we've to write solution for Nth highest salary, if we use limit and offset concept then we've to use offset (N-1) but it shows syntax error when we use minus operator. What to do in this case??
@ooyessabhi
@ooyessabhi Жыл бұрын
Before Return Statement declare and set another variable as N-1 and use that in query. See the below query for reference: CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT BEGIN DECLARE M INT; SET M=N-1; RETURN ( # Write your MySQL query statement below. SELECT DISTINCT Salary FROM Employee ORDER BY Salary DESC LIMIT M, 1 ); END
@harshrajvaghela699
@harshrajvaghela699 2 жыл бұрын
sir when next video on sql playlist
@pratiksawalkar1531
@pratiksawalkar1531 11 ай бұрын
My Solution: select case when max(rn) = 1 then null else salary end as SecondHighestSalary from (select salary, rank() over( order by salary desc) as rn from Employe)a where rn = 2
@sumibits
@sumibits 2 жыл бұрын
I am looking for SQL guidance… Do you have SQL live course ?
@sumitmittal07
@sumitmittal07 2 жыл бұрын
Hi, You can checkout my SQL playlist where I cover important topics of SQL.
@sakshijain3534
@sakshijain3534 3 ай бұрын
WITH cte AS ( SELECT salary, DENSE_RANK() OVER (ORDER BY salary DESC) AS rown FROM employee ) SELECT CASE WHEN rown = 2 THEN salary ELSE NULL END AS SecondHighestSalary FROM cte;
@AbhishekKumar-eh1ed
@AbhishekKumar-eh1ed Жыл бұрын
The solutions are good sir but if there is a question where we have to find second highest salary from each departments then these solutions would not work I guess.
@nandinisugandhi748
@nandinisugandhi748 Жыл бұрын
you can use partition by clause then
Very Famous SQL Interview Question | Department Highest Salary
13:39
Did you believe it was real? #tiktok
00:25
Анастасия Тарасова
Рет қаралды 46 МЛН
Heartwarming: Stranger Saves Puppy from Hot Car #shorts
00:22
Fabiosa Best Lifehacks
Рет қаралды 19 МЛН
2nd Highest Salary || Nth Highest Salary || LIMIT keyword in SQL - Part 4
11:35
Naveen AutomationLabs
Рет қаралды 33 М.
SQL Query | How to find employees with highest salary in a department
10:38
SQL Interview Questions and Answers | SQL Interview Questions | SQL Live Interview
10:41
Lotus IT Hub training institute
Рет қаралды 2,5 М.