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 |
|
vikranth9b
Starting Member
2 Posts |
Posted - 2008-04-09 : 14:32:29
|
| This is the TABLE I haveID BRANCH STATUS1 A ACTIVE1 B INACTIVE1 C INACTIVE2 B INACTIVE2 C INACTIVE2 D INACTIVE3 A ACTIVE3 B ACTIVE3 C ACTIVE4 B ACTIVE5 D INACTIVE----------------------------------------------------------------Following is the desired View that I need for the above table. Any ID which has atleast one ACTIVE branch will have ACTIVE status and any company which have all of its branches INACTIVE will have INACTIVE status. Thanks for your helpID STATUS1 ACTIVE2 INACTIVE3 ACTIVE4 ACTIVE5 INACTIVE |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-04-09 : 14:50:30
|
SELECT ID, CASE MAX(CASE WHEN Status = 'Active' THEN 1 ELSE 0 END)WHEN 1 THEN 'Active'ELSE 'Inactive'END AS StatusFROM TableGROUP BY ID E 12°55'05.25"N 56°04'39.16" |
 |
|
|
vikranth9b
Starting Member
2 Posts |
Posted - 2008-04-09 : 14:59:24
|
| Thanks Peso |
 |
|
|
|
|
|