Jump to content

Recommended Posts

I have database records as;

 

date,symbol,close price

--------------------------

01/01/2009 MSFT 10

01/01/2009 MSFT 10

01/01/2009 IBM 10

01/01/2009 MSFT 10

01/01/2009 APPL 10

 

What I need is the output as;

 

Date MSFT IBM APPL

-------------------------------

01/01/2008 10 20 30

01/01/2008 10 20 30

01/01/2008 10 20 30

01/01/2008 10 20 30

01/01/2008 10 20 30

01/01/2008 10 20 30

 

Can you help pls. Many Thx

Link to comment
https://forums.phpfreaks.com/topic/147406-php-crosstab-or-pivot-query/
Share on other sites

Hi, I did read that b4, and here is my query, but it returns zeros on v1, and v2, not sure, what I am doing wrong.

 

select PX_DATE,

IF(ID_SYMBOL='1283',PX_CLOSE,'') AS V1,

IF(ID_SYMBOL='1247',PX_CLOSE,'') AS V2

from history_px

WHERE (PX_DATE >='2007-09-01' AND PX_DATE <='2009-01-01')

AND (ID_SYMBOL = '1283' OR ID_SYMBOL = '1247')

GROUP BY PX_DATE

 

Appreciate all your kind help and support. Thx

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.