gpt4 book ai didi

sql-server - SQL Server "Invalid column name"错误 |新手

转载 作者:行者123 更新时间:2023-12-01 10:47:21 24 4
gpt4 key购买 nike

我正忙于自学 SQL Server,使用 SQL Server Management Studio。这是产生错误的代码:

SELECT SalesPersonID, COUNT(SalesOrderID), YEAR(OrderDate) AS SalesYear
FROM Sales.SalesOrderHeader
GROUP BY SalesYear;

为什么会抛出这个错误?

Invalid column name 'SalesYear'.

最佳答案

Invalid column name 'SalesYear'.



此列不会出现在表 SalesOrderHeader
SELECT SalesPersonID, COUNT(SalesOrderID), YEAR(OrderDate) AS SalesYear
FROM Sales.SalesOrderHeader GROUP BY YEAR(OrderDate)

关于sql-server - SQL Server "Invalid column name"错误 |新手,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49462037/

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