Coding Interview Resources
52.2K subscribers
710 photos
7 files
401 links
This channel contains the free resources and solution of coding problems which are usually asked in the interviews.

Managed by: @love_data
Download Telegram
📊 SQL Interview Queries – Intermediate Level

━━━━━━━━━━━━━━

Query 01: Find employees earning more than the average salary

SELECT *
FROM employees
WHERE salary > (SELECT AVG(salary) FROM employees);

Query 02: Find department-wise employee count

SELECT department, COUNT(*) AS emp_count
FROM employees
GROUP BY department;

Query 03: Find departments with average salary greater than 60,000

SELECT department
FROM employees
GROUP BY department
HAVING AVG(salary) > 60000;

Query 04: Fetch employees who do not belong to any department

SELECT e.*
FROM employees e
LEFT JOIN departments d
ON e.department_id = d.department_id
WHERE d.department_id IS NULL;

Query 05: Find second highest salary

SELECT MAX(salary)
FROM employees
WHERE salary < (SELECT MAX(salary) FROM employees);

Query 06: Get highest salary in each department

SELECT department, MAX(salary)
FROM employees
GROUP BY department;

Query 07: Fetch employees hired in the last 6 months

SELECT *
FROM employees
WHERE hire_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH);

Query 08: Find duplicate email IDs

SELECT email, COUNT(*)
FROM employees
GROUP BY email
HAVING COUNT(*) > 1;

Query 09: Rank employees by salary within each department

SELECT *,
RANK() OVER (PARTITION BY department ORDER BY salary DESC) AS rank
FROM employees;

Query 10: Fetch top 2 highest paid employees from each department

SELECT *
FROM (
SELECT *,
DENSE_RANK() OVER (PARTITION BY department ORDER BY salary DESC) AS rnk
FROM employees
) t
WHERE rnk <= 2;

🔥 Show some love with a reaction ❤️
7
𝗣𝗹𝗮𝗰𝗲𝗺𝗲𝗻𝘁 𝗔𝘀𝘀𝗶𝘀𝘁𝗮𝗻𝗰𝗲 𝗣𝗿𝗼𝗴𝗿𝗮𝗺 𝗶𝗻 𝗗𝗮𝘁𝗮 𝗦𝗰𝗶𝗲𝗻𝗰𝗲 𝗮𝗻𝗱 𝗔𝗿𝘁𝗶𝗳𝗶𝗰𝗶𝗮𝗹 𝗜𝗻𝘁𝗲𝗹𝗹𝗶𝗴𝗲𝗻𝗰𝗲 𝗯𝘆 𝗜𝗜𝗧 𝗥𝗼𝗼𝗿𝗸𝗲𝗲😍

Deadline: 18th January 2026

Eligibility: Open to everyone
Duration: 6 Months
Program Mode: Online
Taught By: IIT Roorkee Professors

Companies majorly hire candidates having Data Science and Artificial Intelligence knowledge these days.

𝗥𝗲𝗴𝗶𝘀𝘁𝗿𝗮𝘁𝗶𝗼𝗻 𝗟𝗶𝗻𝗸👇

https://pdlink.in/4qHVFkI

Only Limited Seats Available!