filmov
tv
SQL Query to Find Nth Highest Salary Using DENSE_RANK | Top SQL Interview Question Explained

Показать описание
🚀 In this video, we break down a common SQL interview question: How do you find the N-th highest salary from a table?
You'll learn how to solve it using the DENSE_RANK() window function.
🔍 What we cover:
How DENSE_RANK() works in SQL
Writing a query to get the 3rd highest salary
📚 Perfect for: SQL beginners, data analysts, and anyone preparing for SQL interviews.
✅ Sample Query Included
✅ Step-by-step Explanation
✅ Beginner Friendly
you can use below create table and insert statements for your practice:
-- 1. Create table
CREATE TABLE employee_tbl (
id INT,
name VARCHAR(100),
salary INT
);
-- 2. Insert values
INSERT INTO employee_tbl (id, name, salary) VALUES
(1, 'Alice', 5000),
(2, 'Bob', 7000),
(3, 'Charlie', 6000),
(4, 'David', 7000),
(5, 'Eve', 8000),
(6, 'Frank', 6000),
(7, 'Grace', 9000);
🧠 Want more SQL questions? Subscribe and hit the bell icon 🔔 for more tutorials!
#SQL #SQLInterview #DenseRank #NthHighestSalary #WindowFunctions
You'll learn how to solve it using the DENSE_RANK() window function.
🔍 What we cover:
How DENSE_RANK() works in SQL
Writing a query to get the 3rd highest salary
📚 Perfect for: SQL beginners, data analysts, and anyone preparing for SQL interviews.
✅ Sample Query Included
✅ Step-by-step Explanation
✅ Beginner Friendly
you can use below create table and insert statements for your practice:
-- 1. Create table
CREATE TABLE employee_tbl (
id INT,
name VARCHAR(100),
salary INT
);
-- 2. Insert values
INSERT INTO employee_tbl (id, name, salary) VALUES
(1, 'Alice', 5000),
(2, 'Bob', 7000),
(3, 'Charlie', 6000),
(4, 'David', 7000),
(5, 'Eve', 8000),
(6, 'Frank', 6000),
(7, 'Grace', 9000);
🧠 Want more SQL questions? Subscribe and hit the bell icon 🔔 for more tutorials!
#SQL #SQLInterview #DenseRank #NthHighestSalary #WindowFunctions