---
source_url: https://docs.dolphindb.cn/zh/error_codes/S02048.html
fetched_at: 2026-05-19T09:10:06Z
category: error_codes
title: S02048
sha1: 96df1fb79a3e627373b08828bd81daf25fa52f0a
---

# S02048

## 错误代码

S02048

## 报错信息

Order-sensitive functions are not allowed in ORDER BY clause within an OVER clause.
RefId: S02048

## 错误原因

分析函数中的 ORDER BY 子句中使用序列相关函数（如滑动窗口函数，`prev`，`next`
等）时，不能保证每次执行相同代码都返回相同的结果，因此不允许在 ORDER BY 子句中使用序列相关函数。

```dolphindb
id = `XOM`GS`AAPL
val = 102.1 33.4 73.6
date = 2020.01.01 2020.01.02 2020.01.01
t = table(id, val, date);

select sum(val) over (order by msum(val, 2)) from t;
select [67108864] sum(val) over (order by msum(val, 2) asc range between unbounded preceding and current row) as sum from t => Order-sensitive functions are not allowed in ORDER BY clause within an OVER clause. RefId:S02048
```

## 解决办法

修改 SQL 语句或使用自定义函数（不推荐）。

```dolphindb
def summ(val, window) {
  return msum(val, window)
}

select sum(val) over (order by summ(val, 2)) from t;
```
