gpt4 book ai didi

sql - SQL联接子查询

转载 作者:行者123 更新时间:2023-12-03 21:07:24 25 4
gpt4 key购买 nike

我尝试寻找问题的答案,但未能获得真正有用​​的答案。
我已经写了一个sql代码,但似乎找不到问题所在。
是否可以在“ FROM”部分中放置一个子查询?

SELECT S2.ITEM,
S1.SHOP_ORDER,
S1.OPERATION_NO,
S1.START_DATE,
S1.QTY_GOODS,
S1.QTY_ENTERED,
S1.QTY_MRB
FROM (SELECT SHOP_ORD_RPT.OPERATION_NO,
SHOP_ORD_RPT.SHOP_ORDER
FROM FLAME.SHOP_ORD_RPT
WHERE SHOP_ORD_RPT.OPERATION_NO = 110
OR SHOP_ORD_RPT.OPERATION_NO = 370) AS S1
JOIN (SELECT SHOP_ORD.SHOP_ORDER
FROM FLAME.SHOP_ORD
WHERE SHOP_ORD.ITEM = '3A2375'
OR SHOP_ORD.ITEM = '3A2703')AS S2
ON S1.SHOP_ORDER = S2.SHOP_ORDER;


运行脚本时收到的错误是:


SQL命令未正确结束


如果有人可以提供帮助,我将不胜感激。
非常感谢你-
露丝

最佳答案

尝试在ASFROM子查询之后删除JOIN关键字,如下所示

SELECT S2.ITEM, S1.SHOP_ORDER, S1.OPERATION_NO, S1.START_DATE,S1.QTY_GOODS, S1.QTY_ENTERED, S1.QTY_MRB
FROM (
SELECT SHOP_ORD_RPT.OPERATION_NO, SHOP_ORD_RPT.SHOP_ORDER
FROM FLAME.SHOP_ORD_RPT
WHERE SHOP_ORD_RPT.OPERATION_NO =110
OR SHOP_ORD_RPT.OPERATION_NO =370
) S1
JOIN (
SELECT SHOP_ORD.SHOP_ORDER
FROM FLAME.SHOP_ORD
WHERE SHOP_ORD.ITEM ='3A2375'
OR SHOP_ORD.ITEM ='3A2703'
) S2
ON S1.SHOP_ORDER = S2.SHOP_ORDER;

关于sql - SQL联接子查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18718444/

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