我收到错误:第11/13行错误:ORA-00979:不是以下代码的GROUP BY表达式。
SELECT p.project_name,
CASE
WHEN :P42_DATE_RANGES = 'Monthly' THEN To_char(b.date_sys, 'Month')
WHEN :P42_DATE_RANGES = 'Daily' THEN To_char(b.date_sys, 'MM/DD/YYYY')
WHEN :P42_DATE_RANGES = 'Weekly' THEN To_char(Trunc(b.date_sys, 'IW'), 'MM/DD/YYYY')
END AS my_date,
CASE
WHEN :P42_DATE_RANGES = 'Monthly' THEN Trunc(b.date_sys, 'MM')
WHEN :P42_DATE_RANGES = 'Daily' THEN Trunc(b.date_sys)
WHEN :P42_DATE_RANGES = 'Weekly' THEN Trunc(b.date_sys, 'IW')
END AS Dates_,
Count(DISTINCT i.id) AS count_of_ingested,
SUM(hrc.highlighted_count) AS count_of_highlighted,
SUM(hrc.redacted_count) AS count_of_redacted
FROM customer c
inner join project p
ON c.id = p.id_customer
inner join batch b
ON p.id = b.id_project
left outer join ingested i
ON b.id = i.id_batch
left outer join (SELECT hc.id AS id_ingested,
highlighted_count,
redacted_count
FROM (SELECT i.id,
Count(DISTINCT h.id) AS highlighted_count
FROM ingested i
left outer join highlighted h
ON i.id = h.id_ingested
GROUP BY i.id) hc
join (SELECT i.id,
Count(DISTINCT r.id) AS
redacted_count
FROM ingested i
left outer join redacted r
ON i.id = r.id_ingested
GROUP BY i.id) rc
ON hc.id = rc.id) hrc
ON i.id = hrc.id_ingested
WHERE b.date_sys BETWEEN To_date(:P42_START_DATE) AND To_date(:P42_END_DATE)
GROUP BY p.project_name,
CASE
WHEN :P42_DATE_RANGES = 'Monthly' THEN To_char(b.date_sys, 'Month')
WHEN :P42_DATE_RANGES = 'Daily' THEN
To_char(b.date_sys, 'MM/DD/YYYY')
WHEN :P42_DATE_RANGES = 'Weekly' THEN
To_char(Trunc(b.date_sys, 'IW'), 'MM/DD/YYYY')
END
当我将Dates_添加到group by的最后时,这似乎也没有帮助,因为我得到了错误:第42/26行错误:ORA-00904:"日期":无效标识符
1条答案
按热度按时间mrfwxfqh1#
不能将列alias添加到
group by
子句中;使用原始列名或整个表达式:和
group by
子句: