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)
 Retrive data from same table.

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-12-11 : 07:56:06
Fernando writes "Hi,

for some reason (stupidity maybe) I can't solve this problem...

I have a table with this information:

ID | SerialNumber | Result

1 | 123 | Pass

2 | 125 | Fail

3 | 234 | Pass

I just want a select that shows how many pass and fail...

Like this:

Pass | Fail

2 | 1

Symple! I guess :("

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-11 : 07:59:31
select sum(case when result = 'pass' then 1 else 0 end) AS [Pass],
sum(case when result = 'fail' then 1 else 0 end) AS [Fail]
from yourtablenamehere


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -