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.
Author |
Topic |
kashyap81
Starting Member
9 Posts |
Posted - 2008-06-07 : 06:47:04
|
lets say we have two tables:ItemTableItemID Name1 Apple2 Ball3 CatItemTypeTableItemID Type1 12 12 23 2I want a select statement that returns something along these lines:ItemID Type1 12 'Various'3 2basically if an Item has a single corresponding Type in the ItemTypeTable then it should return the Type, otherwise it should return 'Various' (or null or zero)DiaTree.comD.I.P. Pvt Ltd |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-07 : 10:24:28
|
select itemid,case when min(type) < max(type) then 'Various'ELSE CAST(min(type) AS varchar(12))end as typefrom table1group by itemidorder by itemid E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|