Oracle decode has Aggregate functions

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.