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
 Transact-SQL (2000)
 Count - Please help

Author  Topic 

rintus
Starting Member

26 Posts

Posted - 2008-09-18 : 13:31:35
I have got the student name and the subject each student is taking. Suppose the student is taking 2 courses in 'MF' and 3 courses in 'CA.'
I was wondering how to count them.

So the output becomes -

Steve MF 2
Steve CA 3

select a.name Student_Name
,left(b.sub,2)
from student a
,subject b
where b.rod_id = a.row_id
and (left(b.sub,2) = 'MF'
or left(b.sub,2) = 'CA'
or left(b.sub,2) = 'MC'
or left(b.sub,2) = 'OR'
or left(b.sub,2) = 'CM'
or left(b.sub,2) = 'SS')
order by 1
with ur

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-18 : 13:34:56
I have given you solutions in last two posts. you can easily derive total solution by merging from them. Try it out yourselves and post if you face any problems.
Go to Top of Page

rintus
Starting Member

26 Posts

Posted - 2008-09-18 : 13:51:01
Yeah man its there......Thanks for reminding me and sorry for the trouble.....
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-18 : 13:53:39
quote:
Originally posted by rintus

Yeah man its there......Thanks for reminding me and sorry for the trouble.....


Try it out and let us know if you face any problems
Go to Top of Page

rintus
Starting Member

26 Posts

Posted - 2008-09-18 : 14:10:42
Thanks man but I have already got it to work...thanks a lot
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-18 : 14:11:28
quote:
Originally posted by rintus

Thanks man but I have already got it to work...thanks a lot


Cool
Go to Top of Page
   

- Advertisement -