Oracle SQL下一天未分组
zebra_time的数据类型为日期 结果:Oracle SQL下一天未分组,sql,oracle,Sql,Oracle,zebra_time的数据类型为日期 结果: 2014年1月6日 2014年1月6日 2014年1月6日 2014年1月6日 2014年1月6日 2014年1月6日 2014年1月6日 2014年1月6日 2014年1月6日 2014年1月6日 2014年1月6日 2014年1月6日 2014年1月6日 2014年1月6日 2014年1月6日 2014年1月6日 为什么不将它们分组? 是否应该只有一个2014年1月6日?日期类型包含时间,即使它没有显示 select next_day(zeb
2014年1月6日
2014年1月6日
2014年1月6日
2014年1月6日
2014年1月6日
2014年1月6日
2014年1月6日
2014年1月6日
2014年1月6日
2014年1月6日
2014年1月6日
2014年1月6日
2014年1月6日
2014年1月6日
2014年1月6日
2014年1月6日 为什么不将它们分组?
是否应该只有一个2014年1月6日?日期类型包含时间,即使它没有显示
select
next_day(zebra_time, 'mon'),
from builds
where
zebra_time >= '01-jan-2014'
group by next_day(zebra_time, 'mon');
您可以使用
trunc
删除日期的时间部分,并使分组按预期运行。由于zebra_time的数据类型是date,因此它实际上包含日期和时间部分。由于NLS设置,时间部分不会显示。因此,如果每个zebra_时间之间的时间部分不同,即使按zebra_时间分组,也会得到多行
尝试:
及
TRUNC仅按日期删除时间部分和组
参考资料:
select
trunc(next_day(zebra_time, 'mon'))
from builds
where
zebra_time >= '01-jan-2014'
group by trunc(next_day(zebra_time, 'mon'));
select
to_char(next_day(zebra_time, 'mon'), 'MM/DD/YYYY HH12:MI:SS AM'),
from builds
where
zebra_time >= '01-jan-2014'
group by to_char(next_day(zebra_time, 'mon'), 'MM/DD/YYYY HH12:MI:SS AM');
select
trunc(next_day(zebra_time, 'mon')),
from builds
where
zebra_time >= '01-jan-2014'
group by trunc(next_day(zebra_time, 'mon'));