我已经找到了解决这个问题的方法,但是如果其中一个列是子查询,我如何将它包含在组中,或者我需要将它包含在组中。我会在这里粘贴查询。ORA-00979:不是GROUP BY表达式?
SELECT s.customerid, s.denomid,
(SELECT su.quantity
FROM stockupdations su
WHERE s.customerid = su.custid
AND s.denomid = su.denomid
AND s.curid = su.curid) AS cur_stock, c.name AS cus_name, d.denomname AS denom,
cur.curcode AS currency
FROM stock s
LEFT JOIN customers c
ON s.customerid = c.custid
LEFT JOIN denomination d
ON d.denomid = s.denomid
LEFT JOIN currency cur
ON cur.curid = s.curid
GROUP BY s.denomid, s.customerid, c.name, d.denomname, cur.curcode
ORDER BY s.customerid ASC
作为'SUM','COUNT')? 你想达到什么目的? 请张贴输入/期望输出。 – shahkalpesh 2010-10-13 19:24:08
@shahkalpesh:结果与使用'DISTINCT'相同,只是更多的输入 - 查看[AskTom了解更多信息](http://asktom.oracle.com/pls/asktom/f?p=100:11: 0 :::: P11_QUESTION_ID:32961403234212)。拥有GROUP BY子句不需要使用聚合函数。 – 2011-03-11 03:50:16