Skip to main contentSkip to solution

Consider the following table 'EMPLOYEE':

EmpIDENameSalaryDept
101Anil41000HR
102Atul55000Sales
103Jyoti50000Marketing
104Sumit29000Security
105Nidhi38000HR
106Anand48000Marketing

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

✅ Correct Option: 2

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.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question