SQL Interview Set 1
SQL Interview Set 1
sql
SELECT ColumnName, COUNT(*)
FROM TableName
GROUP BY ColumnName
HAVING COUNT(*) > 1;
5. What is the difference between INNER JOIN and LEFT JOIN?
- INNER JOIN: Returns records that match in both tables.
- LEFT JOIN: Returns all records from the left table, and matching records from the
right table (NULL if no match).
6. Explain window functions and provide an example.
Window functions operate on a set of rows related to the current row, without
collapsing them into a single output.
Example:
sql
SELECT EmployeeID, Salary,
RANK OVER (PARTITION BY DepartmentID ORDER BY Salary DESC) AS Rank FROM Employees;