In oracle decode, if the result of the decode function is an aggregate function, you must add the value or item of the decode judgment to the group by statement, for example, www.2cto.com select. C _ FUNDCODE, A.D _ REGISTERDATE, DECODE (. C _ FLAG, '1', NVL (A.F _ TOTALPROFIT, 0), '0', SUM (ROUND (NVL (C. F _ REALSHARES, 0) * NVL (A.F _ UNITPROFIT, 0), 2) BUDGETBALANCE, SUM (NVL (C. F _ REALSHARES, 0) TOTALSHARES, NVL (A.F _ UNITPROFIT, 0) UNITPROFIT, NVL (A.F _ TOTALPROFIT, 0) totalprofit from tprofitschema a, TSTATICS Hares c where A.D _ REGISTERDATE = TO_DATE (: GConfirmDate, 'yyyymmdd') and. C _ FUNDCODE = C. C _ fundcode and instr (NVL (: sFundcode,. C _ FUNDCODE),. C _ FUNDCODE)> 0; in the SQL statement www.2cto.com, the decode function contains the aggregate function sum. How can we write the group statement? Group by. C _ FUNDCODE, A.D _ REGISTERDATE,. C _ FLAG, NVL (A.F _ TOTALPROFIT, 0), NVL (A.F _ UNITPROFIT, 0), NVL (A.F _ TOTALPROFIT, 0) (. C _ FLAG is also added)