您的数据
CREATE TABLE TEST(
id INTEGER NOT NULL
,userId INTEGER NOT NULL
,seed VARCHAR(5) NOT NULL
,assetType VARCHAR(9) NOT NULL
,pinHash VARCHAR(5) NOT NULL
);
INSERT INTO TEST
(id,userId,seed,assetType,pinHash) VALUES
(1,110,'a12H','Bitcoin','q23es'),
(2,111,'r23s','Bitcoin','e2w12'),
(3,111,'y36w','Ethereum','e2w12');
使用
Row_number
作用
SELECT id,
userid,
pinhash
FROM (SELECT id,
userid,
seed,
assettype,
pinhash,
Row_number ()
OVER (
partition BY userid, pinhash
ORDER BY id ASC ) rn
FROM test) T
WHERE rn = 1