Forum Moderators: open

Message Too Old, No Replies

Rearraging data

From one grid to another

         

Red_Eye

3:15 pm on Jun 9, 2006 (gmt 0)

10+ Year Member



I retreive some data from a SQl database that looks like this.

Amount Month Year
12 Jan 2006
25 Feb 2006
62 Mar 2006
45 Jan 2005
32 Feb 2005
33 Mar 2005

I need to rearrange it to this

null Jan Feb Mar
2006 12 25 62
2005 45 32 33

I was thinking about using an array but I think that a data table might work better.

Is there a better way of doing this either in SQL server. I have a feeling that I will need to use brute force. But I am looking for an elegant solution

oxbaker

8:01 pm on Jun 14, 2006 (gmt 0)

10+ Year Member



why dont you just re-write the SQL Select statement to order the necessary values your getting from the database in the order you need them.

you dont have to select the data in any specific order, any way you want to you can do with your select statements.

Its much MUCH easier to get the SQL to order the columns rather than copying and adding to a new DataTable.

hth,
mcm