简体   繁体   English

甲骨文日期时间分组

[英]oracle datetime group by

I want to group data based on date time in oracle eg:- 我想基于日期时间在oracle中对数据进行分组,例如:

03-DEC-13 06:12:03:23,
03-DEC-13 06:12:03:25,
04-DEC-13 08:12:03:23,
04-DEC-13 08:12:03:25

expected result :- 03-DEC-13 06:12:03, 04-DEC-13 08:12:03 预期结果:-03-DEC-13 06:12:03,04-DEC-13 08:12:03

neglect seconds. 忽略秒。

SELECT DISTINCT trunc(some_date, 'MI') FROM some_table;

Question is not completely clear, but I think something like: 问题尚不完全清楚,但我认为是这样的:

select to_char(datefield, 'DD-MMM-YY HH24:MI') , count(*) /* or other grouping */
from   table 
group by to_char(datefield, 'DD-MMM-YY HH24:MI')

If you want to include date/times for which you don't have a value, use something like join with a calendar table or a join with 如果要包括没有值的日期/时间,请使用日历表联接或联接

select  to_date('20000101', 'YYYYMMDD') + level / 24 day_and_hours
from    dual
connect by level <= 100

Check your performance when doing so. 这样做时请检查您的表现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM