gpt4 book ai didi

MySql Where 和 And 语句在 Join 中抛出错误

转载 作者:太空宇宙 更新时间:2023-11-03 11:44:05 25 4
gpt4 key购买 nike

我正在尝试执行下面的语句

SELECT ORDER_MONTH,
SUM(PRICE) as Price
FROM (SELECT EXTRACT(YEAR FROM ORDERDATE) AS ORDER_YEAR,
MONTHNAME(ORDERDATE) AS ORDER_MONTH,
ORDERDATE, PRICE FROM ORDER_ABSTRACT)A
WHERE ORDER_YEAR=2016 AND SKU=4567
GROUP BY MONTH(ORDERDATE)

它的抛出错误为未知列“SKU”

表格说明

 Name Type Collation Attributes Null Default Extra
1 ID varchar(36) utf8_general_ci No None
2 InvoiceNo varchar(20) utf8_general_ci No None
3 RefRetailer varchar(36) utf8_general_ci No None
4 SKU varchar(20) utf8_general_ci No None
5 OrderDate date No None
6 CurrentStatus varchar(10) utf8_general_ci No None
7 Price double No None
8 PaymentType varchar(10) latin1_swedish_ci No None

最佳答案

我没有看到内部连接,而是动态创建的临时表,在此您没有专栏 sku

您可能还需要子选择中的 SKU

SELECT ORDER_MONTH,
SUM(PRICE) as Price
FROM ( SELECT SKU,
EXTRACT(YEAR FROM ORDERDATE) AS ORDER_YEAR,
MONTHNAME(ORDERDATE) AS ORDER_MONTH,
ORDERDATE,
PRICE
FROM ORDER_ABSTRACT) A
WHERE ORDER_YEAR=2016
AND SKU='4567'
GROUP BY MONTH(ORDERDATE)

关于MySql Where 和 And 语句在 Join 中抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39845693/

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