gpt4 book ai didi

sql-server - SQL数据仓库: Incorrect syntax near 'OFFSET'

转载 作者:行者123 更新时间:2023-12-02 23:31:16 25 4
gpt4 key购买 nike

我正在尝试 SQL 数据仓库中的一些功能。我正在尝试使用 SQL 数据仓库提供的示例数据集来尝试 OFFSET。我收到错误:“OFFSET”附近的语法不正确

我检查了数据库兼容性版本,它是130(SQL Server 2016)。以下是我正在尝试的查询:

SELECT [SalesQuotaKey]
,[EmployeeKey]
,[DateKey]
,[CalendarYear]
,[CalendarQuarter]
,[SalesAmountQuota]
FROM [dbo].[FactSalesQuota]
order by [SalesAmountQuota] desc
OFFSET 0 ROWS
FETCH NEXT 10 ROWS ONLY;

查询中是否缺少任何内容,或者我是否需要更改任何设置才能启用 OFFSET?

最佳答案

per docs AzureDW 不支持偏移获取

-- Syntax for Azure SQL Data Warehouse and Parallel Data Warehouse

[ ORDER BY
{
order_by_expression
[ ASC | DESC ]
} [ ,...n ]
]

您可以simulate OFFSET Fetch在 DW 中使用 RowNumber 如下

select * from 
(
SELECT [SalesQuotaKey]
,[EmployeeKey]
,[DateKey]
,[CalendarYear]
,[CalendarQuarter]
,[SalesAmountQuota],
Row_number() over (order by salesamount desc) as rownum
FROM [dbo].[FactSalesQuota]

)tbl
where rownum between 1 and 10

关于sql-server - SQL数据仓库: Incorrect syntax near 'OFFSET' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47346905/

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