我想按dd-mm-yyyy
分组,以显示working_hours
每个雇员(人)每天,但我得到错误消息ORA-00979: not a GROUP BY expression
,当我从GROUP BY
中删除TO_CHAR
时,它工作正常,但这不是我想要的,因为我想group by
天,而不考虑小时,我在这里做错了什么?
SELECT papf.person_number emp_id,
to_char(sh21.start_time,'dd/mm/yyyy') start_time,
to_char(sh21.stop_time,'dd/mm/yyyy') stop_time,
SUM(sh21.measure) working_hours
FROM per_all_people_f papf,
hwm_tm_rec sh21
WHERE ...
GROUP BY
papf.person_number,
to_char(sh21.start_time,'dd/mm/yyyy'),
to_char(sh21.stop_time,'dd/mm/yyyy')
ORDER BY sh21.start_time
1条答案
按热度按时间fkaflof61#
需要仅为
SELECT
子句中定义的列别名:或使用
GROUP BY
子句中的表达式:如果使用
sh21.start_time
,则table_alias.column_name
语法引用表中的基础列,而不是按此选择/分组。