---
source_url: https://docs.dolphindb.cn/zh/error_codes/s02038.html
fetched_at: 2026-05-19T09:09:55Z
category: error_codes
title: S02038
sha1: ec56a25e95c2d6caab4a373dd0ca71c047fb4975
---

# S02038

## 错误代码

S02038

## 报错信息

Order-sensitive or user-defined functions are not allowed in the order by clause […]
for a query over a partitioned table. RefId:S02038

## 错误原因

查询分布式表时不允许在 order by 子句中使用序列相关函数或用户定义函数。以下两个查询都会导致该错误：

```dolphindb
dbName = "dfs://test"
if (existsDatabase(dbName)) {
    dropDatabase(dbName)
}
t = table(1..3 as id)
db = database(dbName, VALUE, 1..3)
pt = db.createPartitionedTable(t, `pt, `id)
pt.append!(t)
def udf(col) {
    return prev(col)
}
select * from pt order by prev(id)
select * from pt order by udf(id)
```

## 解决办法

对分布式表的查询中，是否在 order by 子句中使用了序列相关函数或用户定义函数。
