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 |
thangavelu_arun@yahoo.com
Starting Member
8 Posts |
Posted - 2009-02-18 : 13:02:50
|
Hi,I am in urgent need of the query.For example i haveTable name : tblTemp----------------------ColumnName | Datatype |----------------------GenTime | Datetime |FileType | Char(5) |-----------------------The values areGentime FileType----------------------------------'1/20/2009 6:00:00 PM' 'ABC''1/20/2009 6:00:00 PM' 'PQR''1/20/2009 6:00:00 PM' 'XYZ''1/21/2009 6:00:00 PM' 'ABC''1/21/2009 6:00:00 PM' 'XYZ'The result expected isGentime FileType_ABC FileType_PQR FileType_XYZ--------------------------------------------------------------'1/20/2009 6:00:00 PM' true true true'1/21/2009 6:00:00 PM' true false trueCan anyone please give me the query for the above output?Thanks,Velu |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-18 : 13:09:27
|
[code]SELECT Gentime,MAX(CASE WHEN FileType='ABC' THEN 1 ELSE 0 END) AS FileType_ABC,MAX(CASE WHEN FileType='PQR' THEN 1 ELSE 0 END) AS FileType_PQR,MAX(CASE WHEN FileType='XYZ' THEN 1 ELSE 0 END) AS FileType_XYZFROM tblTempGROUP BY Gentime [/code] |
|
|
thangavelu_arun@yahoo.com
Starting Member
8 Posts |
Posted - 2009-02-18 : 14:53:38
|
Thanks a lot,It really helped. |
|
|
|
|
|