1

How to select non duplicate row data from the table of DolphinDB? I found the function distinct in the manual. I tried the code below, but doesnt work.

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

It seems that distinct can only apply to one column. Is there any solution?

HIPO.L
  • 146
  • 1
  • 7

2 Answers2

1

The function distinct returns unique elements for a single column. If you want to filter out duplicate rows according to multiple columns, strongly recommend function isDuplicated, which was introduced to DolphinDB in version 0.99.

select * from table where isDuplicated([col1, col2], FIRST)=0
Davis Zhou
  • 353
  • 4
  • 6
0

USE master GO

CREATE DATABASE TestDB GO

USE TestDB GO

CREATE TABLE TableA ( ID INT NOT NULL IDENTITY(1,1), Value INT, CONSTRAINT PK_ID PRIMARY KEY(ID)
)


USE TestDB GO

INSERT INTO TableA(Value) VALUES(1),(2),(3),(4),(5),(5),(3),(5)

SELECT * FROM TableA

SELECT Value, COUNT(*) AS DuplicatesCount FROM TableA GROUP BY Value


Output:-

enter image description here

Try This Sql Statements It's Working