select * from table1 then i will get the following
************************************************** **
Ticker col2 col3 col4 col5
----------------
BRK.A2003-05-02 70400.000.0078500.00
FARM2003-05-02 326.253.60370.99
GREY2003-05-02 680.004.00832.00
----------------------
BRK.A2003-05-09 72700.000.0078500.00
FARM2003-05-09 313.003.60370.99
GREY2003-05-09 655.004.00832.00
----------------------
BRK.A2003-05-16 73550.000.0078500.00
FARM2003-05-16 311.503.60370.99
GREY2003-05-16 649.904.00832.00
-----------------------
BRK.A2003-05-23 73850.010.0077000.00
FARM2003-05-23 317.253.60370.99
GREY2003-05-23 665.004.00832.00
-----------------------
BRK.A2003-05-30 71000.000.0075900.00
FARM2003-05-30 322.003.60370.99
GREY2003-05-30 657.004.00832.00
************************************************** **
but my output should be as follows
***********************************************
Ticker Item 5/2/2003 5/9/2003 5/16/2003 5/23/2003 5/30/2003
----------------------
BRK.A col3 70400.00 72700.00 73550.00 73850.01 71000.00
col4 0.00 0.00 0.00 0.00 0.00
col5 78500.00 78500.00 78500.00 77000.00 75900.00
----------------------
FARM col3 326.25 313.00 311.50 317.25 322.00
col4 3.60 3.60 3.60 3.60 3.60
col5 370.99 370.99 370.99 370.99 370.99
----------------------
GREY col3 680.00 655.00 649.90 665.00 657.00
col4 4.00 4.00 4.00 4.00 4.00
col5 832.00 832.00 832.00 832.00 832.00
**********************************************
can anyone helpme how 2 create the query in order 2 obtain the required outputHi
It looks like you are wanting a pivot table. It is usually better to do this
on the client.
If you don't want to write the code to do it then something like
http://www.rac4sql.net/ can be used.
You can also do in the database, but these may be slow:
http://support.microsoft.com/defaul...b;EN-US;q175574
http://www.sqlteam.com/item.asp?ItemID=2955
John
"kalyan" <kalikoi@.yahoo.com> wrote in message
news:98907965.0410260358.259c792b@.posting.google.c om...
> if i query like
> select * from table1 then i will get the following
> ************************************************** **
> Ticker col2 col3 col4 col5
> ----------------
> BRK.A 2003-05-02 70400.00 0.00 78500.00
> FARM 2003-05-02 326.25 3.60 370.99
> GREY 2003-05-02 680.00 4.00 832.00
> ----------------------
> BRK.A 2003-05-09 72700.00 0.00 78500.00
> FARM 2003-05-09 313.00 3.60 370.99
> GREY 2003-05-09 655.00 4.00 832.00
> ----------------------
> BRK.A 2003-05-16 73550.00 0.00 78500.00
> FARM 2003-05-16 311.50 3.60 370.99
> GREY 2003-05-16 649.90 4.00 832.00
> -----------------------
-
> BRK.A 2003-05-23 73850.01 0.00 77000.00
> FARM 2003-05-23 317.25 3.60 370.99
> GREY 2003-05-23 665.00 4.00 832.00
> -----------------------
> BRK.A 2003-05-30 71000.00 0.00 75900.00
> FARM 2003-05-30 322.00 3.60 370.99
> GREY 2003-05-30 657.00 4.00 832.00
> ************************************************** **
> but my output should be as follows
> ***********************************************
> Ticker Item 5/2/2003 5/9/2003 5/16/2003 5/23/2003 5/30/2003
> ----------------------
> BRK.A col3 70400.00 72700.00 73550.00 73850.01 71000.00
> col4 0.00 0.00 0.00 0.00 0.00
> col5 78500.00 78500.00 78500.00 77000.00 75900.00
> ----------------------
> FARM col3 326.25 313.00 311.50 317.25 322.00
> col4 3.60 3.60 3.60 3.60 3.60
> col5 370.99 370.99 370.99 370.99 370.99
> ----------------------
> GREY col3 680.00 655.00 649.90 665.00 657.00
> col4 4.00 4.00 4.00 4.00 4.00
> col5 832.00 832.00 832.00 832.00 832.00
> **********************************************
> can anyone helpme how 2 create the query in order 2 obtain the required
output
No comments:
Post a Comment