---
source_url: https://docs.dolphindb.cn/zh/error_codes/S02053.html
fetched_at: 2026-05-19T09:10:12Z
category: error_codes
title: S02053
sha1: 9ebfb856ab24642094d650abdece10a9092481ff
---

# S02053

## 错误代码

S02053

## 报错信息

`The select clause with DISTINCT keyword must contain all ORDER BY
columns` RefId: S02053

## 错误原因

SQL 语句中带有 DISTINCT 关键字，且 order by 子句所包含的列未出现在 DISTINCT 中。

```dolphindb
def createMyTable(n) {
    intv = take(1..10, n)
    symbol = take(`a`b`c, n)
    id = rand(100, n)
    strv = take("abs" + string(1..10), n)
    doublev = rand(10.0, n)
    return table(intv, strv, doublev, id, symbol)
}

n = 100
t = createMyTable(n)

select DISTINCT id from t order by intv; // 报错
select DISTINCT intv, id from t order by intv; // 正常
```

## 解决办法

将 order by 中所有出现列添加至 select 中。
