digitalalpha Posted March 1, 2009 Share Posted March 1, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/147406-php-crosstab-or-pivot-query/ Share on other sites More sharing options...
fenway Posted March 1, 2009 Share Posted March 1, 2009 Read this. Quote Link to comment https://forums.phpfreaks.com/topic/147406-php-crosstab-or-pivot-query/#findComment-773708 Share on other sites More sharing options...
digitalalpha Posted March 4, 2009 Author Share Posted March 4, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/147406-php-crosstab-or-pivot-query/#findComment-776335 Share on other sites More sharing options...
fenway Posted March 4, 2009 Share Posted March 4, 2009 Then you didn't follow it correctly... I don't see anything generating the column names you want, nor checking their values. Quote Link to comment https://forums.phpfreaks.com/topic/147406-php-crosstab-or-pivot-query/#findComment-776437 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.