【发布时间】:2016-02-25 16:38:51
【问题描述】:
所以,我需要查询一个表并显示每天的计数,即使该计数为零。我尝试了类似下面的方法,但它没有显示计数为零的天数。有人有其他想法吗?使用甲骨文,顺便说一句。非常感谢!!
with the_dates as (
select to_date('080114','MMDDYY') + level - 1 as the_date
from dual
connect by level <= to_date('011716', 'MMDDYY')
- to_date('080114', 'MMDDYY') + 1
)
select distinct trunc(a.the_date), count(*)
from the_dates a
left outer join TableFoo f on a.the_date = to_date(admit_date, 'MMDDYYYY')
where f.customer_num = 10
group by trunc(a.the_date)
order by trunc(a.the_date);
【问题讨论】: