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 |
|
Ally
Starting Member
10 Posts |
Posted - 2012-07-20 : 14:21:26
|
| Hi All,I have a table with Run_date , JobID,Status, Table_Name columnsSome jobids have more than 1 tables.If one of the status has atleast one F I like to put status F for same JobID.Run_Date JobID Status Table_name2012-07-20 50030 P Table12012-07-20 50030 F Table22012-07-20 50030 P Table3How can I put query above table to get result like :Run_Date JobID Status2012-07-20 50030 F ThanksAlly |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-07-20 : 14:39:10
|
| [code]select Run_Date,JobID,CASE WHEN SUM(CASE WHEN Status = 'F' THEN 1 END)>0 THEN 'F' ELSE MAX(Status) ENDfrom tablegroup by Run_Date,JobID[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Ally
Starting Member
10 Posts |
Posted - 2012-07-20 : 14:53:24
|
It works.Thanks a lot. Allyquote: Originally posted by visakh16
select Run_Date,JobID,CASE WHEN SUM(CASE WHEN Status = 'F' THEN 1 END)>0 THEN 'F' ELSE MAX(Status) ENDfrom tablegroup by Run_Date,JobID ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-07-20 : 22:18:13
|
| wc------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|