Search Postgresql Archives

Problem with SELECT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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...?


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
       message can get through to the mailing list cleanly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux