Subqueries & CTEs · Question 12 · Medium
Subqueries & CTEs question 12
Table Faculty:
fid | name | dept | salary
1 | Anand | CSE | 90000
2 | Bhavna | CSE | 120000
3 | Charu | ECE | 75000
4 | Dhruv | ECE | 75000
5 | Esha | MECH | 60000
6 | Firoz | CSE | 105000
What does this query return?
SELECT name
FROM Faculty
WHERE salary = (SELECT DISTINCT salary
FROM Faculty
ORDER BY salary DESC
LIMIT 1 OFFSET 1);
- Bhavna
- Anand
- Firoz
- Charu; Dhruv
Answer and explanation
Answer: C. Firoz
Explanation: The subquery sorts the distinct salaries in descending order (120000, 105000, 90000, ...), skips one and returns the next: 105000, the second highest. Firoz earns that salary.
Previous: Table Faculty: fid | name | dept | salary 1 | Anand | CSE | 90000 2 | Bhavna |… · Next: Table Members: mid | name 1 | Geeta 2 | Hari 3 | Imran 4 | Jaya Table Loans…
Practise subqueries & ctes
Try a fresh set of subqueries & ctes questions with an explanation after every answer, free and without signing up: Subqueries & CTEs practice. Or sit a full placement mock test.
More subqueries & ctes questions
- Table Faculty: fid | name | dept | salary 1 | Anand | CSE | 90000 2 | Bhavna |…
- Table Faculty: fid | name | dept | salary 1 | Anand | CSE | 90000 2 | Bhavna |…
- Table Faculty: fid | name | dept | salary 1 | Anand | CSE | 90000 2 | Bhavna |…
- Table Members: mid | name 1 | Geeta 2 | Hari 3 | Imran 4 | Jaya Table Loans…
- Table Marks: student | subject | score Kavya | Maths | 88 Kavya | Physics | 70…
- In the query below, how is the inner query logically evaluated?
- Table Marks: student | subject | score Kavya | Maths | 88 Kavya | Physics | 70…
- Table Marks: student | subject | score Kavya | Maths | 88 Kavya | Physics | 70…
- Table Faculty: fid | name | dept | salary 1 | Anand | CSE | 90000 2 | Bhavna |…
- Table Members: mid | name 1 | Geeta 2 | Hari 3 | Imran 4 | Jaya Table Loans…
More sql practice
Window Functions · NULL Handling · SQL Functions & CASE · UNION, INTERSECT & EXCEPT · Tables, Keys & Constraints · DML & Transactions · SELECT, WHERE & ORDER BY · SQL Joins
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge