Difficult Transact-SQL Query - TechRepublic
General discussion
October 16, 2002 at 01:29 AM
bgibilaro

Difficult Transact-SQL Query

by bgibilaro . Updated 23 years, 8 months ago

Hey there,

This is a problem I simply have not been able to wrap my brain around. First, the basics, I am

running MS SQL Server 2000 on Windows XP Pro for the client and Windows 2000 Server for the

server.

So here is my problem, I havea table that looks something like this:


————————————
FILE_NO | DATE_TYPE | DATE |
————————————

123 | typeA | 10/23/02|

456 | typeA | 10/21/02|

456 | typeB | 10/25/02|

789 | typeA | 10/12/02|

789 | typeB | 10/24/02|

789 | typeC | 10/24/02|
————————————

What I want to do is write a select statement that will return the information in this format:


———————————————
FILE_NO | typeA | typeB | typeC |
———————————————

123 | 10/23/02| NULL | NULL |

456 | 10/21/02| 10/25/02 | NULL |

789 | 10/12/02| 10/24/02 | 10/26/02|
———————————————

So basically I want to know the dates of each date type that exist for each file number. Keep in
mind that in reality, my table contains thousands of rows, so performance will be a concern here.

Any help you can offer here would be greatly appreciated.

This discussion is locked

All Comments