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)
 Question about grouping

Author  Topic 

informer
Starting Member

2 Posts

Posted - 2006-09-18 : 10:25:52
I am trying to group various document types into groups. For example if the doc type is ST, YT, and DP, I would like this to belong to a group known as 'failed'. If the doc type is NM, NF, LK, I would like this to belong to another group known as 'passed'. I am not sure how to do this.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-09-18 : 10:32:03
something like this

select case when doc_type in ('ST', 'YT', 'DP') then 'failed'
when doc_type in ('NM', 'NF', 'LK') then 'passed'
end,
. . .
from table
group by case when doc_type in ('ST', 'YT', 'DP') then 'failed'
when doc_type in ('NM', 'NF', 'LK') then 'passed'
end



KH

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-18 : 11:28:11
else 'unknown' ?



Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-09-18 : 11:30:43
quote:
Originally posted by Peso

else 'unknown' ?



Peter Larsson
Helsingborg, Sweden


I think in Exams only Pass or Fail and no Unknown

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

informer
Starting Member

2 Posts

Posted - 2006-09-20 : 07:37:29
Thanks. That is exactly what I needed.
Go to Top of Page
   

- Advertisement -