Click to See Complete Forum and Search --> : customize sql header result


vinothrao84
10-10-2007, 10:51 PM
hi,

In my sql table having the following data

fund_name.....unit_price..........date
GF.................2.3............10/10/2007
IF.................2.5..............07/10/2007
BF................1.5..............01/10/2007
GF................1.3.............06/10/2007
GF................0.9.............07/10/2007
IF.................2.5.............11/07/2007
BF................1.9..............20/09/2007
BF................1.8..............02/10/2007
IF................1.4..............10/05/2007
GF................1.7.............08/10/2007
more records continue...

can i create a sql select script that return as below result

GF........IF........BF.........Date
2.3......2.5.......1.5......10/10/2007
1.3......1.4.......1.9......10/10/2007
0.9......2.5.......1.8......10/10/2007
1.7.................1.4......10/10/2007

for the Date it can have the where clause statement.

i want to make the fund_name as the column header result of sql statement.

please help me. i'm stuck.

Thx.

mattyblah
10-11-2007, 01:33 AM
please post how you logically constructed your desired result table.

balazagi
10-16-2007, 09:40 AM
Looks like you are wish to create columns from rows in a table. Table pivoting is a technique used for this purpose. There is a good description and an example of a similar task here: http://en.wikipedia.org/wiki/Pivot_table have a look and see if this helps! good luck