我寫這樣的查詢...集團通過函數列
select to_char(e_date, 'MON/YYYY') as Month , location_code, count(employee_number) from
...
現在我想通過月和Location_code組。那麼如何在group by子句中使用to_char(e_date, 'MON/YYYY') as Month
?
編輯:
select to_char(vheda.e_date, 'MON/YYYY') as Months , hla.location_code, count(vheda.employee_number) emp_count from
virtu.virt_hr_emp_daily_attendance vheda
inner join per_all_people_f papf on vheda.party_id = papf.party_id
inner join per_all_assignments_f paaf on papf.person_id = paaf.person_id
inner join hr_locations_all hla on paaf.location_id = hla.location_id
where (trunc(sysdate) between PAPF.EFFECTIVE_START_DATE and PAPF.EFFECTIVE_END_DATE)
--and (vheda.e_in_time is not null)
and vheda.e_duration <> 0
and (trunc(sysdate) between PAAF.EFFECTIVE_START_DATE and PAAF.EFFECTIVE_END_DATE)
and vheda.e_date between '1-aug-2014' and '31-oct-2014'
group by hla.location_code, vheda.e_date
order by vheda.e_date
OUT PUT時使用GROUP BY子句group by to_char(vheda.e_date, 'MON/YYYY'), hla.location_code
:
ORA-00979:不是GROUP BY表達 00979. 00000 - 「不是一個GROUP BY表達「 *原因:
*操作: 錯誤在行:58列:37
可能重複的[ORA-00979不是按表達式分組](http://stackoverflow.com/questions/1520608/ora-00979-not-a-group-by-expression) – Ben 2014-12-02 09:15:55