SQL Interview Questions
SQL Interview Questions
Ans. The correct order of execution in SQL is FROM, WHERE , GROUP BY,
HAVING, SELECT, DISTINCT, ORDER BY and LIMIT.
Ans. UNION removes duplicate rows from the combined result set, whereas
UNION ALL includes all rows from each query without removing duplicates.
Ans. INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN, are common types of
joins used to combine rows from multiple tables based on specified
conditions or relationships.
4. If one table has 10 rows and another has 20 rows what is the
minimum and maximum number of rows we get after joining
both the tables?
Ans. The minimum number of rows we get after joining both the tables will
be 0. The minimum number of rows will be 0 if there are no matching rows
based on the join condition between Table A and Table B.
The maximum number of rows we get after joining both the tables will be 30.
The maximum number of rows will be 30, which is the sum of rows from
Table A (10 rows) and Table B (20 rows), because a full join includes all rows
from both tables.
5. Find the 3rd highest salary of employee based on department.
From EMPLOYEES
Group by DEPARTMENT
Limit 3;
FROM employees
GROUP BY manager_name;