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 |
girisignin
Starting Member
11 Posts |
Posted - 2009-09-29 : 08:55:43
|
This is my data tableACD ID EventDate FailflagValue 111 10 june 2009 16:10 4 111 10 june 2009 17:30 0111 11 june 2009 12:15 4111 11 june 2009 13:20 0222 10 june 2009 13:10 4222 10 june 2009 14:00 0Output should be like thisACDID FailDate OKDate 111 10 june 2009 16:10 10 june 2009 17:30111 11 june 2009 12:15 11 june 2009 13:20222 10 june 2009 13:10 10 june 2009 14:00The above query should be written in sql server 2000.help please…giri |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-09-29 : 09:00:34
|
[code]select ACD,ID,MAX(CASE WHEN FailFlagValue = 4 THEN EventDate ELSE NULL END) AS FailDate,MAX(CASE WHEN FailFlagValue = 0 THEN EventDate ELSE NULL END) AS OkDatefrom tablegroup by ACD,ID[/code] |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-09-29 : 09:02:19
|
Read about Cross-tab reports in sql server help fileMadhivananFailing to plan is Planning to fail |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-09-29 : 09:02:42
|
MadhivananFailing to plan is Planning to fail |
|
|
girisignin
Starting Member
11 Posts |
Posted - 2009-09-30 : 00:17:55
|
hi visakh16ACDID will be failed several times , so we can not take it into group bygiri |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-09-30 : 00:25:36
|
then show some data to illustrate your real scenario and output you need. |
|
|
girisignin
Starting Member
11 Posts |
Posted - 2009-09-30 : 01:06:39
|
ACDID EventDate FailflagValue 111 - 10 june 2009 16:10 - 4 111 - 10 june 2009 17:30 - 0111 - 11 june 2009 12:15 - 4111 - 11 june 2009 13:20 - 0222 - 10 june 2009 13:10 - 4222 | 10 june 2009 14:00 | 0Output should be like thisACDID FailDate OKDate 111 - 10 june 2009 16:10 - 10 june 2009 17:30111 - 11 june 2009 12:15 - 11 june 2009 13:20222 - 10 june 2009 13:10 - 10 june 2009 14:00 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-09-30 : 01:10:25
|
[code]select ACD,MAX(CASE WHEN FailFlagValue = 4 THEN EventDate ELSE NULL END) AS FailDate,MAX(CASE WHEN FailFlagValue = 0 THEN EventDate ELSE NULL END) AS OkDatefrom tablegroup by ACD,DATEADD(dd,DATEDIFF(dd,0,EventDate),0)[/code] |
|
|
|
|
|
|
|