Basic Select, Where, Distinct
Basic Select, Where, Distinct
🔹 3. HAVING Clause
Q:Departments paying over ₹1,000,000 combined salary.
🔹 5. JOINs
projects.manager_idref.
Q:List projects with their manager names (assuming
employees.id
).
● F
ULL OUTER JOIN– includes all rows from both tables(synergisticit.com,
synergisticit.com)
🔹 7. Subqueries
Q:Employees earning above average salary.
● It can affect execution and results especially if it filters out rows before aggregations or
outer joins (reddit.com)
indow functions (a.k.a. analytics functions) like ROW_NUMBER(), AVG() OVER(...) etc., are
W
common in interviews (arxiv.org).
PDATE employees e
U
SET bonus = bonus + 5000
WHERE e.department = 'Sales';
● E
xplainSQL relationships: One-to-one, One-to-many,Many-to-many
(synergisticit.com)
if (!set.add(num)) {
}
}
🔹 1. Find employees whose name starts with
'A'
SELECT * FROM employees
FROM employees
GROUP BY department;
FROM employees
FROM employees
Or using subquery:
FROM (
FROM employees
) AS temp;
FROM employees e
SELECT AVG(salary)
FROM employees
);
FROM departments d
GROUP BY d.dept_name;
🔹 9. Get employees who work on more than one
project
Assuming a
employee_project
table with many-to-many
relationship:
FROM employee_project
GROUP BY employee_id
FROM employees
GROUP BY name
FROM salaries
GROUP BY MONTH(payment_date);
🔹 15. Display employee names and their
manager’s name
Assuming
manager_id
is a foreign key in the same
employees
table:
FROM employees e