What will be the output of the query given below?
Micron technical mcq question, verified with a worked answer. Free to practise - no sign-up.
What will be the output of the query given below?
SELECT Name FROM Employee WHERE salary IN (25000,40000,8000);
Employee Table:
| ID | Name | Salary | Designation |
|---|---|---|---|
| 101 | Rajesh | 8000 | System Engr |
| 102 | Pritam | 5000 | System Engr |
| 103 | Sudeep | 10000 | Lead |
| 104 | Ramesh | 40000 | Manager |
| 105 | John | 30000 | Lead |
| 106 | Anjali | 20000 | IT Analyst |
Show answer & explanation
Answer: B. Rajesh, Ramesh
The WHERE clause filters rows where salary matches any value in the IN list (25000, 40000, 8000). From the table, only Rajesh (8000) and Ramesh (40000) have matching salaries. Anjali's salary is 20000 (not in the list), so she is excluded.
Step-by-step Derivation:
Step-by-step execution:
- Query: SELECT Name FROM Employee WHERE salary IN (25000,40000,8000)
- Check each row:
- ID 101, Rajesh, Salary 8000 → 8000 is IN (25000,40000,8000) ✓ Include
- ID 102, Pritam, Salary 5000 → 5000 is NOT IN (25000,40000,8000) ✗ Exclude
- ID 103, Sudeep, Salary 10000 → 10000 is NOT IN (25000,40000,8000) ✗ Exclude
- ID 104, Ramesh, Salary 40000 → 40000 is IN (25000,40000,8000) ✓ Include
- ID 105, John, Salary 30000 → 30000 is NOT IN (25000,40000,8000) ✗ Exclude
- ID 106, Anjali, Salary 20000 → 20000 is NOT IN (25000,40000,8000) ✗ Exclude
- Result: Rajesh, Ramesh (in order of appearance in table)