首页 > 解决方案 > 如何从 dolphindb 表中删除重复行?

问题描述

如何从 DolphinDB 的表中选择不重复的行数据?我distinct在手册中找到了该功能。我尝试了下面的代码,但不起作用。

select distinct(col1,col2) from table
=====================================
The function [distinct] expects 1 argument(s), but the actual number of arguments is: 2

select distinct([col1,col2]) from table
=====================================
The argument for 'distinct' must be a typed vector

似乎 distinct 只能应用于一列。有什么解决办法吗?

标签: dolphindb

解决方案


该函数distinct返回单个列的唯一元素。如果你想根据多列过滤掉重复的行,强烈推荐function isDuplicated,它是在DolphinDB 0.99版本中引入的。

select * from table where isDuplicated([col1, col2], FIRST)=0

推荐阅读