Problem with SELECT - Mailing list pgsql-general

From marwis1978
Subject Problem with SELECT
Date
Msg-id 1191839284.399984.156680@57g2000hsv.googlegroups.com
Whole thread Raw
Responses Re: Problem with SELECT
List pgsql-general
I have a following table
-----+--------
 day | quantity
-----+--------

where day is a date and quantity is an integer value. Now I need to
make a SELECT statement on this table which returns me a full
information on a whole month, it means day>='2007-10-01' and day
<'2007-11-01' but if there is no any quantity for some days a need to
have 0 as a result. Assume that I have following records:

INSERT INTO tmp_table(day, quantity) VALUES('2007-10-01', 23);
INSERT INTO tmp_table(day, quantity) VALUES('2007-10-04', 23);
INSERT INTO tmp_table(day, quantity) VALUES('2007-10-09', 23);

How can I make a SELECT statement to receive:
-----------------+--------
 day            | quantity
-----------------+--------
2007-10-01 | 23
2007-10-02 | 0
2007-10-03 | 0
2007-10-04 | 23

and so on...?


pgsql-general by date:

Previous
From: Goboxe
Date:
Subject: Re: Partitioned tables, rules, triggers
Next
From: michi
Date:
Subject: PostgreSQL Storage: Sorted by Primary Key?