Conference Presentation Resume Tips
Conference Presentation Resume Tips
SELECT DISTINCT salary FROM employees ORDER BY salary DESC LIMIT 1 OFFSET (N-1);
SELECT name, COUNT(*) FROM employees GROUP BY name HAVING COUNT(*) > 1;
SELECT department_id, name, salary FROM employees e WHERE salary = (SELECT MAX(salary) FROM
employees WHERE department_id = e.department_id);
https://chatgpt.com/c/67e4caae-14e8-8010-96ab-03c43ec58566 1/9
30/03/2025, 19:38 Conference Presentation Resume Tips
DELETE FROM employees WHERE id NOT IN ( SELECT MIN(id) FROM employees GROUP BY name,
salary, department_id );
SELECT e1.name AS emp1, e2.name AS emp2, e1.salary FROM employees e1, employees e2 WHERE
e1.salary = e2.salary AND e1.id <> e2.id;
These are some of the most commonly asked SQL queries in interviews. Let me know if you need more!
🚀
yes i need
SELECT DISTINCT salary FROM employees ORDER BY salary DESC LIMIT 1 OFFSET 2;
OR using DENSE_RANK() :
https://chatgpt.com/c/67e4caae-14e8-8010-96ab-03c43ec58566 2/9
30/03/2025, 19:38 Conference Presentation Resume Tips
SELECT salary FROM ( SELECT salary, DENSE_RANK() OVER (ORDER BY salary DESC) as rnk FROM
employees ) temp WHERE rnk = 3;
12. Find Employees Who Have a Higher Salary Than the Average Salary
sql Copy Edit
SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM employees);
OR using JOIN:
SELECT hire_date, COUNT(*) AS count FROM employees GROUP BY hire_date HAVING COUNT(*) > 1;
-- First record SELECT * FROM employees ORDER BY id ASC LIMIT 1; -- Last record SELECT *
FROM employees ORDER BY id DESC LIMIT 1;
https://chatgpt.com/c/67e4caae-14e8-8010-96ab-03c43ec58566 3/9
30/03/2025, 19:38 Conference Presentation Resume Tips
18. Find Employees Who Have Worked for More Than 5 Years
sql Copy Edit
UPDATE employees SET col1 = col1 + col2, col2 = col1 - col2, col1 = col1 - col2;
SELECT salary FROM ( SELECT salary, DENSE_RANK() OVER (ORDER BY salary DESC) AS rnk FROM
employees ) ranked WHERE rnk <= 5;
https://chatgpt.com/c/67e4caae-14e8-8010-96ab-03c43ec58566 4/9
30/03/2025, 19:38 Conference Presentation Resume Tips
SELECT * FROM employees e LEFT JOIN leaves l ON e.id = l.employee_id AND YEAR(l.leave_date)
= YEAR(CURDATE()) WHERE l.employee_id IS NULL;
25. Find Employees Who Have the Same Salary as Someone Else
SELECT e1.name, e1.salary FROM employees e1 JOIN employees e2 ON e1.salary = e2.salary AND
e1.id <> e2.id;
These are some of the most commonly asked SQL queries in interviews.
Let me know if you need more advanced queries or explanations! 🚀
yes give me
26. Find the Employee(s) with the Maximum Salary in Each Department
https://chatgpt.com/c/67e4caae-14e8-8010-96ab-03c43ec58566 5/9
30/03/2025, 19:38 Conference Presentation Resume Tips
SELECT name, salary, SUM(salary) OVER (ORDER BY salary ROWS BETWEEN UNBOUNDED PRECEDING AND
CURRENT ROW) AS running_total FROM employees;
SELECT * FROM employees e WHERE NOT EXISTS ( SELECT 1 FROM employees WHERE manager_id =
e.employee_id );
SELECT name, COUNT(*) AS name_count FROM employees GROUP BY name HAVING COUNT(*) > 1;
35. Get the Employee(s) with the Second Highest Salary in Each Department
https://chatgpt.com/c/67e4caae-14e8-8010-96ab-03c43ec58566 6/9
30/03/2025, 19:38 Conference Presentation Resume Tips
SELECT department_id, name, salary FROM ( SELECT department_id, name, salary, DENSE_RANK()
OVER (PARTITION BY department_id ORDER BY salary DESC) AS rank FROM employees ) ranked
WHERE rank = 2;
36. Find the Difference Between the Highest and Lowest Salary
SELECT * FROM employees WHERE manager_id = (SELECT employee_id FROM employees WHERE name =
'John Doe');
SELECT name, salary, RANK() OVER (ORDER BY salary DESC) AS salary_rank FROM employees;
41. Find Employees Who Have Been Paid More Than Their Manager
https://chatgpt.com/c/67e4caae-14e8-8010-96ab-03c43ec58566 7/9
30/03/2025, 19:38 Conference Presentation Resume Tips
42. Get the Names of Employees Who Have Never Been Promoted
43. Find Employees Whose Name Starts and Ends with a Specific Letter
44. Find Employees Who Are in the Same Department as Their Manager
47. Find Employees Who Have a Salary Within 10% of the Highest Salary
SELECT * FROM employees WHERE salary >= (SELECT MAX(salary) * 0.9 FROM employees);
48. Retrieve Employees Who Have Worked on More Than One Project
sql
https://chatgpt.com/c/67e4caae-14e8-8010-96ab-03c43ec58566 8/9
30/03/2025, 19:38 Conference Presentation Resume Tips
Copy Edit
SELECT employee_id, COUNT(DISTINCT project_id) AS project_count FROM employee_projects
GROUP BY employee_id HAVING COUNT(DISTINCT project_id) > 1;
SELECT job_title, COUNT(*) AS count FROM employees GROUP BY job_title ORDER BY count DESC
LIMIT 1;
These advanced SQL queries cover joins, ranking, analytics, subqueries, aggregations, and
optimization techniques often tested in interviews. 🚀
https://chatgpt.com/c/67e4caae-14e8-8010-96ab-03c43ec58566 9/9