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 2005 Forums
 Analysis Server and Reporting Services (2005)
 Query help

Author  Topic 

cipriani1984
Constraint Violating Yak Guru

304 Posts

Posted - 2009-02-25 : 05:20:34
Hi,

I have the following data.

student_id, comp_status
001, 1
001, 2
002, 2
003, 2
003, 2

The data above is a list of students who have enrolled onto an institute and the reason there are multiple rows for one student is because they study more than one course.

Is there a way I can return list of students who just dont have one at all. Because if i do comp_status <> 1 then itll still bring back student 001 which I dont want to see.

Thanks.

cipriani1984
Constraint Violating Yak Guru

304 Posts

Posted - 2009-02-25 : 06:44:12
Ive found solution now. thanks anyways
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-02-25 : 07:03:56
SELECT student_id from table1 group by student_id
having min(comp_status) > 1



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -