Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Multiple conditions on a single column

Author  Topic 

thanuksha
Starting Member

1 Post

Posted - 2007-03-13 : 07:26:11
How to check multiple conditions on a single column with and condition.
Lets say theres a table with columns student No and subject.
Data will be as follow.
Student No Subject
-------------- ----------
00A Math
00A Science
00B Math
00B Arts
00C Science
00D Math
00D Science
00D Atrs
00E Science

I want to get Students who are doing both Maths and Science. The results would be 00A and 00D
Please help me to solve this

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-13 : 07:51:53
[code]
select [Student_No]
from sometable
where Subject in ('Maths', 'Science')
group by [Student_No]
having count(*) = 2
[/code]


KH

Go to Top of Page
   

- Advertisement -