Sako Posted March 27, 2011 Share Posted March 27, 2011 Hi, I am looking for a way to do a crosstab. I've read plenty of articles on mySQL "crosstabs", but I still haven't found one that suits my needs. Here is my table: Ticker - Date - Field1 MSFT - 20110325 - 1 MSFT - 20110322 - 0 CSCO - 20110325 - 1 CSCO - 20110322 - 1 I want the format below as a result: 20110325 - 20110322 MSFT - CSCO CSCO - Basically, if Field1 is 1, then show the ticker. The hardest part is how would I name the column name as the date instead of manually writing "select ... As 20110325 ..." Any help? Quote Link to comment https://forums.phpfreaks.com/topic/231864-crosstab-column-names/ Share on other sites More sharing options...
fenway Posted April 1, 2011 Share Posted April 1, 2011 You'll have to do this mostly in php -- first select the tickers, then go back and craft a fancy sql statement. Quote Link to comment https://forums.phpfreaks.com/topic/231864-crosstab-column-names/#findComment-1195698 Share on other sites More sharing options...
Sako Posted April 2, 2011 Author Share Posted April 2, 2011 do you know any articles on how to do that? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/231864-crosstab-column-names/#findComment-1195954 Share on other sites More sharing options...
fenway Posted April 3, 2011 Share Posted April 3, 2011 I'm sure i have references to such articles somewhere -- i'll dig around. Quote Link to comment https://forums.phpfreaks.com/topic/231864-crosstab-column-names/#findComment-1196257 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.