Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Pivot one column

$
0
0

I have a query that returns data like this:

VisitDt

2013-01-30 10:15:00.000
2012-09-11 00:00:00.000
2012-08-17 14:00:00.000
2012-07-27 16:35:00.000
2012-06-04 14:00:00.000
2012-05-06 20:00:00.000
2012-04-21 00:00:00.000

I want to Pivot it as 7 separate columns, like this:

VisitDT1 VisitDT2 VisitDT3 VisitDT4 VisitDT5 VisitDT6 VisitDT7

2013

-01-30 2012-09-11 2012-08-17 2012-07-27 2012-06-04 2012-05-06 2012-04-21

The dates returned will always be different from the example above.  Most examples I've seen for Pivot reference the contents of the column somehow.  I can't do that since the contents will change.  I feel like this should be simple but can't find a good way to do it.  Any help is appreciated.

Thanks, Andre


André


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>