gpt4 book ai didi

sql-server - 子查询中 Order By 的 SQL 错误

转载 作者:行者123 更新时间:2023-12-01 17:32:55 25 4
gpt4 key购买 nike

我正在使用 SQL Server 2005。

我的查询是:

SELECT (
SELECT COUNT(1) FROM Seanslar WHERE MONTH(tarihi) = 4
GROUP BY refKlinik_id
ORDER BY refKlinik_id
) as dorduncuay

错误:

The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.

如何在子查询中使用 ORDER BY

最佳答案

这是你得到的错误(强调我的错误):

The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.

那么,如何避免这个错误呢?我猜想,通过指定 TOP 是一种可能性。

SELECT (
SELECT TOP 100 PERCENT
COUNT(1) FROM Seanslar WHERE MONTH(tarihi) = 4
GROUP BY refKlinik_id
ORDER BY refKlinik_id
) as dorduncuay

关于sql-server - 子查询中 Order By 的 SQL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/985921/

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