I have a table like below
user_id | month, | value
---------+------------+--------
1 | 2013-02-01 | 1
1 | 2013-01-01 | 0
1 | 2013-03-01 | 5
2 | 2013-02-01 | 1
Supposedly a user_id can not have same month more than one.
Let's say I can put the months I want to query in the query statement. like below
SELECT user_id, (bla bla bla) AS '2013-03-01', (bla bla bla) AS '2013-02-01'
How do I get a result like below, with minimum number of queries and post-processing (e.g. using python or php)?
user_id | 2013-03-01 | 2013-02-01 | 2013-01-01
---------+------------+------------+------------
1 | 5 | 1 | 0
2 | NULL | 1 | NULL