[SQL] Inconsistent data type of data in different cases in case statement ora-00932:inconsistent datatypes:expected number got CHAR

Source: Internet
Author: User
Tags case statement

Ora-00932:inconsistent datatypes:expected number got CHAR

00932.00000-"Inconsistent datatypes:expected%s got%s"

1  Case  2when         '0'then  NVL (tx_cnt,0 )3         ELSE4END  act_tx_cnt,
TX_CNT is number type, which is the count after group by
TOT_TX_CNT is VARCHAR2 (XX) type

Therefore, the above error message appears.

Solution: Transform data to convert Number data to VACHAR2 (XX) type
1  Case  2when'0'thenCAST(NVL (act_tx_cnt,0  asVARCHAR2(83ELSE4  END act_tx_cnt,          

Finish

The complete code is a small note:

The number of trades, the amount of the transaction, the number of valid trades, the amount of the transaction in the statistics file.
1 SELECTEpstfbok. File_dt,2 Epstfbok. File_type,3 Epstfbok. FILE_SRC,4 epstfbok.fil_sts,5 Epstfbok. Rcv_fil,6 Epstfbok. TOT_TX_CNT,7 Epstfbok. Tot_tx_amt,8 Epstfbok. RMK,9 Epstfbok. Bat_no,TenNVL (chui_cnt,0) chui_cnt, One CaseEpstfbok. File_type when '0' Then CAST(NVL (ACT_TX_CNT,0) as VARCHAR2(8))ELSEEpstfbok. Tot_tx_cntENDact_tx_cnt, A CaseEpstfbok. File_type when '0' Then CAST(NVL (Act_tx_amt,0) as VARCHAR( the))ELSEEpstfbok. Tot_tx_amtENDAct_tx_amt - fromEpstfbok - Left JOIN the(SELECTBat_no,COUNT(*) chui_cnt fromEpstordrWHEREAlt_flg='1' GROUP bybat_no) -M onEpstfbok.bat_no=M.bat_no - Left JOIN -(SELECTBat_no,COUNT(*) act_tx_cnt,SUM(Tx_amt) Act_tx_amt fromEpstordrGROUP bybat_no) +N onEpstfbok.bat_no=N.bat_no - ORDER byEpstfbok. Bat_nodesc;

[SQL] Inconsistent data type of data in different cases in case statement ora-00932:inconsistent datatypes:expected number got CHAR

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.