首页 > 解决方案 > 错误:无法匹配 UNION 类型整数和字符变化 [SQL 状态 = 42804]

问题描述

我正在合并两个视图,但超出了错误。请帮我解决这个问题。一些值在那里被硬编码,需要在最终视图中提取相同的值。我在 redshift 中使用以下查询-

询问:

DROP VIEW IF EXISTS jgbl.vw_jgvcc_crm_case_activity CASCADE;

CREATE OR REPLACE VIEW jgbl.vw_jgvcc_crm_case_activity
AS
SELECT case_number as "CASE Number",
       parent_case_number as "Parent Case Number",
       date_opened as "Date Opened",
       number_of_questions as "Number of Questions",
       case_record_type as "CASE Record Type",
       NULL as "Sub Type",
       category as "Category",
       NULL as "Sub Category",
       country as Country,
       customer_type as "Customer Type",
       primary_account_subtype as "Primary Account Subtype",
       source as Source,
       call_center_location as "Call Center Location",
       region as Region,
       customer_region as "Customer Region",
       NULL as "AE",
       NULL as "PQC",
       'ASPAC' as datasource
FROM JG_ASPAC.vw_jgvcc_aspac_crm_activity

UNION ALL
       
SELECT case_num as "CASE Number",
       NULL as "Parent Case Number",
       open_dt as "Date Opened",
       cast(num_of_ques as integer) as "Number of Questions",
       rec_type_nm as "CASE Record Type",
       rec_sub_type as "Sub Type",
       cat_desc as "Category",
       sctgy_desc as "Sub Category",
       custm_latam_ctry_nm as Country,
       acct_type as "Customer Type",
       NULL as "Primary Account Subtype",
       src_in as Source,
       case when alph_fl='Y' then 'Alphanumeric' else 'LATAM Center' end as "Call Center Location",
       'LATAM' as Region,
       NULL as "Customer Region",  
       Case when rec_type_nm='AE/PQC' and rec_sub_type in ('ADVERSE EVENT','AE + PQC') then 'Y' else 'N' End as "AE",
       Case when rec_type_nm='AE/PQC' and rec_sub_type in ('AE + PQC', 'PRODUCT QUALITY COMPLAINT')  then 'Y' else 'N' End as "PQC",
       'LATAM' as datasource
FROM JG_LTM.vw_jgvcc_latam_crm_activity as v2
--LEFT JOIN jgbl.dim_iso_reg_cntry as t1 on t1.region = v2.ctry_iso2_cd 
with no schema binding;       

错误:

执行SQL命令时出错:select * from jgbl.vw_jgvcc_crm_case_activity limit 10

错误:无效数字,值“。”,位置 1,类型:整数详细信息:

错误:无效数字,值'.',位置 1,类型:整数代码:1207 上下文:1.0 查询:87576 位置:0 进程:query1_562_87576 [pid=0] ------------- ---------------------------------- [SQL State=XX000] 1 条语句失败。

执行时间:4.81s

标签: amazon-redshiftsql-view

解决方案


推荐阅读