Thursday, March 22, 2012

Count ?

Hi, below tells me all of the students who have failed an exam

select emark, surname, forenames from result, student
where emark=0
and result.netid = student.netid;

im looking for the person who has failed six exams
ive tried:

select emark, surname, forenames from result, student
where emark=0
(select count( surname) where surname >6)
and result.netid = student.netid;

but no luck. Iv'e also tried distinct surname as well.
Can someone point me in the right direction.

Thanxselect student.netid, count(*)
from result, student
where emark=0
and result.netid = student.netid
group by student.netid
having count(*) >= 6;|||that does the trick,
thanx alot.sql

No comments:

Post a Comment