SQL Server dynamic PIVOT query - fields order

referring to solved question SQL Server dynamic PIVOT query?, I am trying to explicity order the fields created by Category (ABC, DEF and GHI) in the new table in a reverse order. I.e., output table now has the following fields (data, ABC, DEF, GHI) and I would like to get (data, GHI, DEF, ABC).

Many thanks D.

  create table temp
(
    date datetime,
    category varchar(3),
    amount money
)

insert into temp values ('1/1/2012', 'ABC', 1000.00)
insert into temp values ('2/1/2012', 'DEF', 500.00)
insert into temp values ('2/1/2012', 'GHI', 800.00)
insert into temp values ('2/10/2012', 'DEF', 700.00)
insert into temp values ('3/1/2012', 'ABC', 1100.00)


DECLARE @cols AS NVARCHAR(MAX),
    @query  AS NVARCHAR(MAX);

SET @cols = STUFF((SELECT distinct ',' + QUOTENAME(c.category) 
            FROM temp c
            FOR XML PATH(''), TYPE
            ).value('.', 'NVARCHAR(MAX)') 
        ,1,1,'')

set @query = 'SELECT date, ' + @cols + ' from 
            (
                select date
                    , amount
                    , category
                from temp
           ) x
            pivot 
            (
                 max(amount)
                for category in (' + @cols + ')
            ) p '


execute(@query)

drop table temp


ANSWERS:


Just change the column list(@cols) like this

SET @cols = Stuff((SELECT DISTINCT ',' + Quotename(c.category)
                   FROM   temp c
                   ORDER  BY ',' + Quotename(c.category) DESC
                   FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 1, '') 


 MORE:


 ? T-SQL dynamic pivot
 ? T-SQL dynamic pivot
 ? T-SQL dynamic pivot
 ? Converting Row to Column dynamically in SQL
 ? I'm currently looking for a dynamic way to convert rows to columns in a specific way in SQL server
 ? Microsoft SQL Server: Adding New Column To Row Instead Of Repeated Values
 ? Joining tables and LEFT JOIN as new Columns in tsql
 ? SQL query which returns variable number of columns for each record combining multiple rows
 ? Convert row to columns SQL dynamically
 ? query to combine multiple columns in one columns