Comprehensive collection of the most frequently asked SQL query interview questions. Covers SELECT operations, JOINs, subqueries, aggregations, window functions, and complex real-world scenarios. Each query is production-ready and commonly asked in technical interviews at top companies.
0%
Overall Progress
0/110
Status
Problem
Level
2.Select specific columns from a table
Easy
3.Filter records using WHERE clause
Easy
4.Sort records in ascending order
Easy
5.Sort records in descending order
Easy
6.Count total number of records in a table
Easy
7.Find the maximum salary
Easy
8.Find the minimum salary
Easy
9.Calculate the average salary
Easy
10.Find the sum of all salaries
Easy
11.Display the first 5 records in SQL
Easy
12.Find distinct values in a column
Easy
13.Filter records with multiple conditions using AND
Easy
14.Filter records with multiple conditions using OR
Easy
15.Find records where a column value is NULL
Easy
16.Find records where a column value is NOT NULL
Easy
17.Find records using the LIKE operator
Easy
18.Find records using the IN operator
Easy
19.Find records within a range using BETWEEN
Easy
20.Alias column names
Easy
21.Concatenate two columns
Easy
22.Convert text to uppercase
Easy
23.Convert text to lowercase
Easy
24.Get the current date
Easy
25.Get the length of a string
Easy
26.Round a number to 2 decimal places
Easy
27.Find employees with salary greater than 50000
Easy
28.Find the first name starting with 'A'
Easy
29.Sort by multiple columns
Easy
30.Use NOT operator
Easy
31.Find the number of employees in each department
Medium
32.Get the highest salary in each department
Medium
33.Find departments with more than 5 employees
Medium
34.Find duplicate emails in the Employee table
Medium
35.Display duplicate records with their count
Medium
36.Delete duplicate records from a table
Medium
37.Find employees without managers
Medium
38.Find employees joined in the last 3 months
Medium
39.Fetch the last 3 records in SQL
Medium
40.Fetch alternate rows (odd rows) from a table
Medium
41.Fetch even rows from a table
Medium
42.Find the second highest salary
Medium
43.Find the Nth highest salary
Medium
44.Find the highest salary without using MAX()
Medium
45.Swap two column values
Medium
46.Perform INNER JOIN between two tables
Medium
47.Perform LEFT JOIN
Medium
48.Perform RIGHT JOIN
Medium
49.Perform FULL OUTER JOIN
Medium
50.Perform SELF JOIN
Medium
51.Fetch common records from two tables without JOIN
Medium
52.Use UNION to combine results
Medium
53.Use UNION ALL
Medium
54.Find employees whose salary is above average
Medium
55.Find the department with the highest employee count
Medium
56.Create a copy of a table
Medium
57.Copy only structure (not data)
Medium
58.Insert data from one table to another
Medium
59.Update records based on a condition
Medium
60.Delete records based on a condition
Medium
61.Find employees with names containing 'an'
Medium
62.Find employees whose names start with A and end with N
Medium
63.Use CASE statement for conditional logic
Medium
64.Find employees hired in a specific year
Medium
65.Calculate age from date of birth
Medium
66.Get the day, month, and year from a date
Medium
67.Find records from the last 7 days
Medium
68.Add a new column to a table
Medium
69.Drop a column from a table
Medium
70.Rename a column
Medium
71.Use ROW_NUMBER() to rank employees by salary
Hard
72.Use RANK() function
Hard
73.Use DENSE_RANK() function
Hard
74.Find the top 3 salaries in each department
Hard
75.Use PARTITION BY in window functions
Hard
76.Calculate running total of salaries
Hard
77.Find the difference between current and previous row
Hard
78.Use LEAD() to get the next row value
Hard
79.Find employees earning more than their manager
Hard
80.Find employees with the same salary
Hard
81.Use CTE (Common Table Expression)
Hard
82.Use recursive CTE to show employee hierarchy
Hard
83.Pivot data (rows to columns)
Hard
84.Unpivot data (columns to rows)
Hard
85.Find employees with salary greater than all in HR department
Hard
86.Find employees with salary greater than any in HR department
Hard
87.Use EXISTS clause
Hard
88.Find departments with no employees
Hard
89.Find the median salary
Hard
90.Find the mode (most frequent value)
Hard
91.Calculate cumulative percentage
Hard
92.Find gaps in sequential numbers
Hard
93.Create a dense sequence of numbers
Hard
94.Find consecutive login dates
Hard
95.Calculate moving average
Hard
96.Find year-over-year growth
Hard
97.Implement full-text search
Hard
98.Find the longest streak of consecutive events
Hard
99.Implement pagination efficiently
Hard
100.Find overlapping date ranges
Hard
101.Find the top performing employee in each department
Hard
102.Calculate retention rate
Hard
103.Transpose rows into comma-separated values
Hard
104.Find customers who purchased both Product A and Product B
Hard
105.Calculate percentile rank
Hard
106.Find the first and last record in each group
Hard
107.Implement a cross join
Hard
108.Find employees with maximum experience in each department
Hard
109.Calculate the difference between max and min salary per department
Hard
110.Find all employees who report to the same manager