Vishnu
Vishnu

Reputation: 31

PostgreSQL selecting rows from table with specified condition

I am using PostgreSQL database. I have a table course(id, c_name) and want to retrieve ids having enrolled to more than one courses

`I am trying following query but it doesn't return any record.

SELECT id FROM sub where c_name = 'comp' and c_name = 'maths'

Any help in this regard?

Upvotes: 1

Views: 401

Answers (1)

Owen
Owen

Reputation: 1736

select id, count(distinct c_name) 
from course 
group by id 
having count(distinct c_name) > 1

Upvotes: 1

Related Questions