Reputation: 31
I am using PostgreSQL database. I have a table course(id, c_name)
and want to retrieve id
s 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
Reputation: 1736
select id, count(distinct c_name)
from course
group by id
having count(distinct c_name) > 1
Upvotes: 1