tribune=# \d schedules
Table "public.schedules"
Column | Type | Modifiers
------------------------+------------------------+--------------------------------------------------------
station_num | integer | not null
database_key | character varying(255) |
air_date | date |
air_time | character varying(255) |
duration | character varying(255) |
\d programs
Table "public.programs"
Column | Type | Modifiers
-----------------------+------------------------+-------------------------------------------------------
id | integer | not null default nextval('programs_id_seq'::regclass)
database_key | character varying(255) | not null
title | character varying(255) |
SELECT COUNT(date_seq) FROM (select '2006-05-08'::date + i as date_seq from generate_series(0,6) s(i)) s1 LEFT JOIN schedules ON (air_date = date_seq ) LEFT JOIN programs ON (programs.database_key = schedules.database_key) WHERE programs.title = $$'Allo, 'Allo$$ GROUP BY date_seq ORDER BY date_seq;
count
-------
11
3
3
27
(4 rows)
should return 7 rows with empty rows showing up as 0