假设我有以下walletid
walletid
ab2
ab2
cd3现在,我想添加一个id,将其更改为:
id walletid
1 ab2
1 ab2
2 cd3发布于 2018-07-05 20:04:06
这就是你要的
SELECT wallets.walletid, wallets_distinct_ids.id
FROM wallets INNER JOIN
(SELECT walletid, row_number() OVER () as id
FROM
(SELECT DISTINCT walletid
FROM wallets) AS wallets_distinct) AS wallets_distinct_ids
ON wallets.walletid = wallets_distinct_ids.walletid解释:
首先,我们创建一个查询,该查询选择walletid
walletid值分配distinct id。现在,我们可以使用来自pt.2的查询作为https://stackoverflow.com/questions/51190309
复制相似问题