user1430989
user1430989

Reputation: 555

Oracle SQL Query TO return rows from a table matching two conditions

I have a table "Employees":

E_ID    E_Name                E_Salary   Grade
01      Hansen, Ola           15,000     HC_1
02      Svendson, Tove        15,000     HC_2
03      Svendson, Stephen     32,000     HC_9
04      Pettersen, Kari       21,000     HC_1
05      Sachin, Tendulkar     21,000     HC_2
06      Brian, Lara           19,000     HC_3

I need to return the Employees Salary that have both HC_1 and HC_2 grades. Can someone help me forming the query for this.

Thank you for your time.

Upvotes: 0

Views: 177

Answers (1)

David Aldridge
David Aldridge

Reputation: 52336

I think you want ...

 Select   e_salary
 from     employees
 where    grade in ('HC_1','HC_2')
 group by e_salary
 having   count(distinct grade) = 2

Upvotes: 2

Related Questions