SQL Practice Questions and Answers
SQL Practice Questions and Answers
SELECT DeptNo, AVG(Salary) FROM Employee GROUP BY DeptNo; . This implies that the salary data is being summarized to show a central tendency within each department, potentially indicating disparities or uniformities in salary distribution.
SELECT COUNT(*) FROM Employee WHERE City = 'Delhi'; . Knowing the number of employees in a specific location can be relevant for resource allocation, planning, and identifying growth or reduction areas within the organization.
SELECT DName FROM Department; . This query is useful for understanding the different departments available in the database, which could be critical for joins or filtering operations in more complex queries.
SELECT City, COUNT(*) FROM Employee WHERE EName LIKE '%SH%' GROUP BY City HAVING MIN(Salary) > 25000 ORDER BY City;
SELECT MAX(Salary) FROM Employee GROUP BY DeptNo HAVING COUNT(*) > 5; . The query groups employees by department and selects the maximum salary, filtering only departments with more than 5 employees to ensure a significant minimum staff size before aggregation.
SELECT DeptNo, COUNT(*) FROM Employee WHERE EName LIKE 'A%' GROUP BY DeptNo;
SELECT EName FROM Employee E JOIN Department D ON E.DeptNo = D.DeptNo WHERE DName IN ('Physics', 'Chemistry') AND Salary > 5000 GROUP BY City HAVING COUNT(*) >= 6;
SELECT DeptNo, SUM(Salary) FROM Employee WHERE City IN ('Mumbai', 'Chennai') GROUP BY DeptNo HAVING COUNT(*) < 10;
SELECT * FROM Employee WHERE DeptNo = 101 ORDER BY Salary DESC;
SELECT EName, DName FROM Employee E JOIN Department D ON E.DeptNo = D.DeptNo WHERE Salary > 50000 AND City = 'Mumbai';