Consider the following table 'EMPLOYEE':
EmpID EName Salary Dept 101 Anil 41000 HR 102 Atul 55000 Sales 103 Jyoti 50000 Marketing 104 Sumit 29000 Security 105 Nidhi 38000 HR 106 Anand 48000 Marketing
If Details of all employees serving in 'HR' dept with salary greater than 40000 is required, then which of the following query should be used?
Consider the following table 'EMPLOYEE':
| EmpID | EName | Salary | Dept |
|---|---|---|---|
| 101 | Anil | 41000 | HR |
| 102 | Atul | 55000 | Sales |
| 103 | Jyoti | 50000 | Marketing |
| 104 | Sumit | 29000 | Security |
| 105 | Nidhi | 38000 | HR |
| 106 | Anand | 48000 | Marketing |
If Details of all employees serving in 'HR' dept with salary greater than 40000 is required, then which of the following query should be used?
Solution
The condition has two parts that must both hold: salary strictly greater than 40000 and department equal to 'HR'. In SQL, WHERE filters rows, > means strictly greater, and AND requires both conditions to be true.
Option 2 does exactly this. Only Anil (41000, HR) satisfies it. Nidhi is in HR but earns 38000.
Option 1: >= includes salary equal to 40000, which is not "greater than". Also, && is not standard SQL for AND.
Option 3: | is not a logical OR in SQL, and HAVING is meant for filtering groups after GROUP BY, not for filtering rows.
Option 4: HAVING is used here instead of WHERE, and >= includes 40000.
Related questions:
2025: 3 June Shift 2
2026: 23 May Shift 1
2025: 13 May Shift 2
2026: 13 May Shift 2