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 |
|
abacusdotcom
Posting Yak Master
133 Posts |
Posted - 2009-10-09 : 08:08:44
|
| Hi AllGood day, good people of sqlteam. I have a table of workflow like process.Kindly see belowreq_id type startdate enddate1 Approval 20/02/09 25/02/091 Response 28/02/09 28/02/091 Resolution 28/02/09 nulland I want an output like thisreq_id approval_startdate approval_enddate response_startdate response_enddate resolution_startdate resolution_enddate1 20/02/09 25/02/09 28/02/09 28/02/09 28/02/09 nullmy approachselect distint req_id ,approval_startdate = (select startdate from tablename where req_id =a.req_id and type= 'approval') ,approval_enddate = (select enddate from tablename where req_id =a.req_id and type= 'approval'),response_startdate = (select startdate from tablename where req_id =a.req_id and type= 'response') ,response_enddate = (select enddate from tablename where req_id =a.req_id and type= 'response'),resolution_startdate = (select startdate from tablename where req_id =a.req_id and type= 'resolution') ,resolution_enddate = (select enddate from tablename where req_id =a.req_id and type= 'resolution')from table nameKindly show me another method of arriving at that without using my method.Thanks a bunchI sign for fame not for shame but all the same, I sign my name. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-09 : 08:21:18
|
| select req_id,max(case when type= 'approval' then startdate end) as approval_startdate,max(case when type= 'approval' then enddate end) as approval_enddate,..from your_tablegroup by req_idMadhivananFailing to plan is Planning to fail |
 |
|
|
abacusdotcom
Posting Yak Master
133 Posts |
Posted - 2009-10-09 : 09:02:02
|
| Thanks a bunch..My first approach took 7 secs to completeThis Mr.Madhivanan yours took 1 sec.. Yes, that's what am looking for :PERFORMANCE:Thanks A LOTI sign for fame not for shame but all the same, I sign my name. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-09 : 09:44:47
|
quote: Originally posted by abacusdotcom Thanks a bunch..My first approach took 7 secs to completeThis Mr.Madhivanan yours took 1 sec.. Yes, that's what am looking for :PERFORMANCE:Thanks A LOTI sign for fame not for shame but all the same, I sign my name.
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|