1

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?

1

1 Answer 1

1
select id, count(distinct c_name) 
from course 
group by id 
having count(distinct c_name) > 1
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Owen. I have tried it and worked perfectly as i want. It was very useful for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.