I have a table like this in my postgres BD:
CREATE TABLE foo(id,type,date,value) AS
SELECT *
FROM ( VALUES
(11::smallint,'A','2016-06-06 19:00:00'::timestamp,81),
(11,'A','2016-06-06 20:00:00',70),
(11,'A','2016-06-06 21:00:00',35),
(11,'B','2016-06-06 19:00:00',2),
(11,'B','2016-06-06 20:00:00',0),
(11,'B','2016-06-06 21:00:00',0)
) as f;
Here is the data,
id | type | date | value
----+------+---------------------+------
11 | A | 2016-06-06 19:00:00 | 81
11 | A | 2016-06-06 20:00:00 | 70
11 | A | 2016-06-06 21:00:00 | 35
11 | B | 2016-06-06 19:00:00 | 2
11 | B | 2016-06-06 20:00:00 | 0
11 | B | 2016-06-06 21:00:00 | 0
And this is the result that i want to get:
ID DATE A B
-----|----------------------|----|---
11 | 2016-06-06 19:00:000 | 81 | 2
11 | 2016-06-06 20:00:000 | 70 | 0
11 | 2016-06-06 21:00:000 | 35 | 0
Any one knows what is the query that i have to make to get this result?