'How to select only one type of value for shared id?
Solution 1:[1]
On MySQL 8+, we can use RANK():
WITH cte AS (
SELECT *, RANK() OVER (PARTITION BY common_id ORDER BY id) rnk
FROM yourTable
)
SELECT id, string, common_id
FROM cte
WHERE rnk = 1;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tim Biegeleisen |


