oracle group by

来源:百度知道 编辑:UC知道 时间:2024/09/23 22:30:14
请问如何按日期字段的某天某月某时分组?
我这样写不可以
group by to_char(date,'yyyy'),to_char(date,'mm'),to_char(date,'dd'),to_char(date,'hh24')
提示不是一个group by 子句。

select to_char(date,'yyyymmddhh24miss'),...
from
table_name
group by to_char(date,'yyyymmddhh24miss');
你group by后面的字段要跟查找的字段一致.

使用group by,必须用group function,比如sum,avg

SELECT column, group_function
FROM table
[WHERE condition]
[GROUP BY group_by_expression]
[HAVING group_condition]
[ORDER BY column];