We had a table previously for user information which contained the pinHash as well
So, for the same userId the pinHash would be same for all the assetTypes.
Now, we are migrating to another table
Which SQL can be used to get all the records with for this migration i.e. distinct userId with pinHash.
N.B: I already did this migration using spring boot where I take all the rows from the first table and then use a HashMap to put only one row of userId in the new table. Still, I would love a SQL for which only distinct userId rows would come as result.
Assuming you always want to report the minimum
id from each set of duplicates, we can use aggregation here:
SELECT MIN(id) AS id, userId, pinHash FROM yourTable GROUP BY userId, pinHash;