SQL Queries: MCQ questions with answers
CS Fundamentals (Placement), Unit 11. 40 SQL Queries questions with explanations (CS Fundamentals (Placement)). Topics: SQL Queries. Take a free test now.
Topics
- SQL Queries: returns, column, constraint, employees, values, highest, default
Key terms: returns, column, constraint, employees, values, highest
Sample questions with answers
Employees per department:
Options: A) SELECT dept, COUNT(*) FROM emp GROUP BY dept B) SELECT dept, COUNT(*) FROM emp ORDER BY dept C) SELECT dept, SUM(dept) FROM emp GROUP BY dept D) SELECT dept, AVG(dept) FROM emp GROUP BY dept
Answer: A) SELECT dept, COUNT(*) FROM emp GROUP BY dept. GROUP BY with aggregate.
To fetch only 5 rows (MySQL/PostgreSQL):
Options: A) TOP 5 B) LIMIT 5 C) FIRST 5 D) ROWS 5
Answer: B) LIMIT 5. SQL Server uses TOP.
Default sort order of ORDER BY:
Options: A) Descending B) Ascending C) Random D) Insertion order
Answer: B) Ascending. ASC.