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 |
senthil_mca80
Starting Member
10 Posts |
Posted - 2008-02-08 : 18:03:31
|
Hi, i need the query for the followingTable: ResultsetTestId status901 Pass901 Pass902 pass902 Fail902 Pass903 Pass903 Blocked904 Pass...Now i want the result set like the followTestId status901 PAss902 Fail903 Blocked904 PassMy scenario is the test id should return pass only all the instance of the test id get passed.Otherwise it should show other status like “Failed” or “ Blocked” …Can anyone help this?Your help is much appreciated. |
|
jdaman
Constraint Violating Yak Guru
354 Posts |
Posted - 2008-02-08 : 18:23:54
|
What if a TestId has a status of Blocked and Fail? Which would win in that scenario? |
 |
|
senthil_mca80
Starting Member
10 Posts |
Posted - 2008-02-08 : 18:27:01
|
IT would be either Blocked or failed |
 |
|
jdaman
Constraint Violating Yak Guru
354 Posts |
Posted - 2008-02-08 : 18:28:58
|
[code]SELECT TestId, CASE MAX(Status) WHEN 0 THEN 'Pass' WHEN 1 THEN 'Fail' WHEN 2 THEN 'Blocked' END AS StatusFROM ( SELECT TestId, CASE Status WHEN 'Pass' THEN 0 WHEN 'Fail' THEN 1 WHEN 'Blocked' THEN 2 END AS Status FROM Resultset ) aGROUP BY TestId[/code] |
 |
|
senthil_mca80
Starting Member
10 Posts |
Posted - 2008-02-08 : 18:40:49
|
Hey you rock....I got my answere.. actually this was a samll portion of my large query. i was struggling to group this data. but finally u gave me a good solution...Thanks a lot man...Senthil |
 |
|
|
|
|