当前位置:网站首页>表达式必须具有与对应表达式相同的数据类型

表达式必须具有与对应表达式相同的数据类型

2022-08-11 08:30:00 hhkun0120

SELECT c.grant_class,
    a.bank_code,
    a.bank_acc_no AS acc_No,
    a.acc_cust_name,
    c.ahr_id_no AS id_no,
    c.ahr_addr  AS address,
    c.ahr_tel,
    c.ahr_rt_phr_or_ipsn,
    to_char(a.finishing_date, 'yyyy-MM-dd') finishing_date,
    '' term_date,
    '' bank_acc_type,
    b.mtn_biz_no cntr_no
  FROM A
  WHERE a.mtn_id  = b.mtn_id
  AND b.mtn_id    = c.mtn_id
  AND b.proc_stat = '4'
  UNION
  SELECT c.grant_class,
    a.bank_code,
    a.bank_acc_no AS acc_No,
    a.acc_cust_name,
    c.ahr_id_no AS id_no,
    c.ahr_addr  AS address,
    c.ahr_tel,
    c.ahr_rt_phr_or_ipsn,
    to_char(a.finishing_date, 'yyyy-MM-dd')finishing_date,
    '' term_date,
    '' bank_acc_type,
    d.cntr_no
  FROM mtn_gen_info a,
    mtn_alt_cntr b,
    GRANT_TRAN_APPL c,
    GRANT_TRANLST d
  WHERE a.mtn_id  = b.mtn_id
  AND b.mtn_id    = c.mtn_id
  AND c.mtn_id    = d.mtn_id
  AND b.proc_stat = '4'
  UNION
  SELECT grant_class,
    bank_code,
    bankacc_no AS acc_No,
    bankacc_name,
    ahr_id_no AS id_no,
    ahr_addr  AS address,
    ahr_tel,
    ahr_rt_phr_or_ipsn,
    to_char(valid_date, 'yyyy-MM-dd'),
    '' term_date,
    bank_acc_type,
    cntr_no
  FROM B
  UNION
  SELECT 'E' grant_class,
    bank_code,
    bank_acc_no AS acc_No,
    acc_cust_name bankacc_name,
    '' AS id_no,
    '' AS address,
    '' ahr_tel,
    '' ahr_rt_phr_or_ipsn,
    '' valid_date,
    '' term_date,
    '' bank_acc_type,
    cntr_no
  FROM E

上述SQL是优化之后的,问题出在下面,之前是a.finishing_date是Date型,下面的'' 是string型,用to_char转换后就可以了。

to_char(a.finishing_date, 'yyyy-MM-dd') finishing_date,

 

原网站

版权声明
本文为[hhkun0120]所创,转载请带上原文链接,感谢
https://blog.csdn.net/hhkun0120/article/details/113181571