简体   繁体   中英

Error code 937, SQL state 42000: ORA-00937: not a single-group group function

I do not know what is the problem

SELECT 
    DP.CODE_VALEUR CODE,
    MAX(VA.CODE_TYPE_VALEUR) CODE_TYPE_VALEUR,
    MAX(VA.NOM_VALEUR) STOCK_NAME,
    (SUM(COURS_ACQ_VALEUR) / SUM(QUANTITE_VALEUR)) CMP,
    MAX(DP.CODE_COMPTE) CODE_COMPTE,
    SUM(DP.QUANTITE_VALEUR) QTEVALEUR,
    round(SUM(DP.VALORISATION_BOURSIERE), 3) VALORISATION_BOURSIERE,
    round((SUM(DP.VALORISATION_BOURSIERE) / SUM(DP.QUANTITE_VALEUR)),
            3) COURS
FROM
    DETAILPORTEFEUILLE DP,
    VALEUR VA
WHERE
    DP.CODE_COMPTE IN (SELECT 
            P.CODE_COMPTE_RATTACHE
        FROM
            PROCURATION P
        WHERE
            P.IDWEB_MASTER = 8
                AND NVL(P.CAN_SEE_PORTEFEUILLE, 0) != 0)
        AND VA.CODE_VALEUR = DP.CODE_VALEUR
        AND DP.QUANTITE_VALEUR > 0
        AND DP.CODE_VALEUR = 'TN0007250012'

A SELECT list cannot include both a group function, such as AVG, COUNT, MAX, MIN, SUM, STDDEV, or VARIANCE, and an individual column expression, unless the individual column expression is included in a GROUP BY clause.

Drop either the group function or the individual column expression from the SELECT list or add a GROUP BY clause that includes all individual column expressions listed.

OR ADD

GROUP BY DP.CODE_VALEUR

为了使用聚合函数SUM,MAX等,您需要至少将数据库告知GROUP BY一列。

尝试添加

GROUP BY DP.CODE_VALEUR

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM