【发布时间】:2011-04-18 10:20:37
【问题描述】:
我正在使用count 和group by 来了解每天有多少订阅者进行购买:
select count(s.email)
from subscriptions s, orders o
where o.subcription_id=s.id
group by s.created_at
结果:
created_at count
------------------
04-04-2011 1
06-04-2011 2
07-04-2011 1
10-04-2011 5
11-04-2011 9
但是我仍然希望空行返回为“0”。我该怎么做呢?请注意,我必须使用 两个 表。
created_at count
------------------
04-04-2011 1
05-04-2011 0
06-04-2011 2
07-04-2011 1
08-04-2011 0
09-04-2011 0
10-04-2011 5
11-04-2011 9
【问题讨论】:
标签: sql postgresql aggregate-functions