我需要从表REPORT_VIEW_PAGE中获取标题,计数和百分比。这很好。
SELECT DISTINCT TITLE, COUNT(TITLE) AS tot, ROUND(COUNT(TITLE)/(
SELECT COUNT(*) FROM REPORT_VIEW_PAGE), 4) AS per
FROM REPORT_VIEW_PAGE
WHERE DAYCOUNT > '0'
GROUP BY TITLE
ORDER BY TITLE ASC
但是,如果尝试检索ID和TYPE,如
SELECT DISTINCT TITLE, ID, TYPE, COUNT(TITLE) AS tot, ROUND(COUNT(TITLE)/(
SELECT COUNT(*) FROM REPORT_VIEW_PAGE), 4) AS per
FROM REPORT_VIEW_PAGE
WHERE DAYCOUNT > '0'
GROUP BY TITLE
ORDER BY TITLE ASC
我收到错误:
ORA-00979:不是GROUP BY表达式 00979. 00000 - "不是GROUP BY表达式" *原因:
*动作:行错误:12列:24
任何人都可以提供帮助。
答案 0 :(得分:1)
您需要按其他列进行分组
SELECT TITLE, ID, TYPE, COUNT(TITLE) AS tot, ROUND(COUNT(TITLE)/(
SELECT COUNT(*) FROM REPORT_VIEW_PAGE), 4) AS per
FROM REPORT_VIEW_PAGE
WHERE DAYCOUNT > '0'
GROUP BY TITLE, Id, TYPE
ORDER BY TITLE ASC