我需要编写P1 / SQL代码,从2018年4月1日(00:00-23:59)到30/4月18日(00:00-23:59)打印行数
答案 0 :(得分:2)
select count(*)
from your_table
where date_column between to_date('01.04.2018 00:00', 'dd.mm.yyyy hh24:mi')
and to_date('30.04.2018 23:59', 'dd.mm.yyyy hh24:mi');
[编辑:每天计算]
select trunc(date_column) date_value,
count(*)
from your_table
where date_column between to_date('01.04.2018 00:00', 'dd.mm.yyyy hh24:mi')
and to_date('30.04.2018 23:59', 'dd.mm.yyyy hh24:mi')
group by trunc(date_column)
order by 1;
答案 1 :(得分:0)
只需在行中打印行即可通过级别功能实现。希望在片段下方有所帮助。
SELECT to_date('04/01/2018','MM/DD/YYYY') + (level -1)
FROM dual
CONNECT BY level <= TO_CHAR(last_day(to_date('04/01/2018','MM/DD/YYYY')),'fmDD');