gpt4 book ai didi

sql - oracle pl/sql ORA-01790 : expression must have same datatype as corresponding expression

转载 作者:行者123 更新时间:2023-12-03 19:26:43 29 4
gpt4 key购买 nike

SELECT SUM(SALES_AMOUNT)SALES,
YEAR,
MONTH,
CATAGORY_ID,
SALES_PERSON_ID,
ITEM_TYPE_ID
FROM APEX_FINAL
where sales_amount is not null
and catagory_id is not null
GROUP BY (YEAR,MONTH,CATAGORY_ID,SALES_PERSON_ID,ITEM_TYPE_ID)

union all

SELECT SUM(SALES_AMOUNT)SALES,
YEAR,
MONTH,
CATAGORY_ID,
'all others' SALES_PERSON_ID,
ITEM_TYPE_ID
FROM APEX_FINAL
where sales_amount is not null
and sales_person_id is null
GROUP BY (YEAR,MONTH,CATAGORY_ID,SALES_PERSON_ID,ITEM_TYPE_ID)

这是我的代码,请帮助我解决我的问题,因为我遇到了错误的数学数据类型,但所有数据类型都相同

最佳答案

销售人员 ID 似乎不匹配。它可能是您表中的 NUMERIC 数据类型。

可能你可以在第一个联合查询中使用 TO_CHAR(SALES_PERSON_ID) ,如下所示。它会帮助你解决问题

SELECT SUM(SALES_AMOUNT)SALES,
YEAR,
MONTH,
CATAGORY_ID,
TO_CHAR(SALES_PERSON_ID) SALES_PERSON_ID,
ITEM_TYPE_ID
FROM APEX_FINAL
where sales_amount is not null
and catagory_id is not null
GROUP BY (YEAR,MONTH,CATAGORY_ID,SALES_PERSON_ID,ITEM_TYPE_ID)

union all

SELECT SUM(SALES_AMOUNT)SALES,
YEAR,
MONTH,
CATAGORY_ID,
'all others' SALES_PERSON_ID,
ITEM_TYPE_ID
FROM APEX_FINAL
where sales_amount is not null
and sales_person_id is null
GROUP BY (YEAR,MONTH,CATAGORY_ID,SALES_PERSON_ID,ITEM_TYPE_ID)

关于sql - oracle pl/sql ORA-01790 : expression must have same datatype as corresponding expression,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24053294/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com