Thanks for your help and suggessions.
Your code is very close to resolving my sorting issue. However, I am still having problems getting it to work so I am taking your suggession and including the table structure with insert statements and sample output.
I would like to sort the date field in DESC order sequententially; then partition the date/amount columns into 6 columns (3 date and 3 amount columns). See example below: I will send also send an attachment - the format changed.
Table Structure
CREATE TABLE #CollectionSummaries(
[Id] [int] IDENTITY(1,1) NOT NULL,
[MeterId] [int] NULL,
[CollectionTime] [datetime] NOT NULL,
[TotalAmount] [decimal](8, 2) NOT NULL,
[UniqueSpaceId] [nvarchar](50) NULL
)
--CONSTRAINT [PK_CollectionSummaries] PRIMARY KEY CLUSTERED
Insert Statement
INSERT INTO #CollectionSummaries
([MeterId]
,[CollectionTime]
,[TotalAmount]
,[UniqueSpaceId])
VALUES(
6146,'2013-04-15 09:20:08.000',12.34,'26254',
6146,'2013-04-15 08:20:08.000',12.34,'26254',
997,'2013-04-08 23:59:31.000',0.50,'CB2397',
997,'2013-03-07 23:17:12.000',0.50,'CB2397',
4351,'2013-03-01 22:59:46.000',4.07,'ED263',
4313,'2013-02-22 22:55:30.000',4.05,'ED647',
997,'2013-02-08 22:24:01.000',0.50,'CB2397',
2644,'2013-01-25 22:10:14.000',3.14,'CB3077',
5026,'2013-01-21 21:06:54.000',15.35,'LT491',
4907,'2012-12-20 20:53:09.000',0.80,'LT379',
4415,'2012-12-08 20:30:38.000',1.25,'ED342',
224,'2012-11-07 20:24:11.000',14.52,'CB3511',
4835,'2012-11-01 20:18:42.000',25.45,'LT8A')
Sample OutPut[/u]
collectionDate1 TotalAmount1 collectionDate2 TotalAmount2collectionDate3 TotalAmount3
4/15/2013 1.50 11/25/2012 2.0010/25/2012 7.00
3/1/2013 22.50 11/17/2012 4.0010/21/2012 9.00
2/1/2013 10.00 11/11/2012 3.0010/15/2012 11.00
1/1/2013 32.50 11/1/2012 5.0010/10/2012 16.00
12/1/2012 11.00 10/27/2012 6.0010/1/2012 17.00