I am trying to group column 1 by their values, and remove duplicate values of column 2 within the group.
For example,
Input
Output
I assume I need to use the function group by column 1 and use distinct to column 2, but I am not sure how to implement it.
CodePudding user response:
SELECT DISTINCT Column_1,Column_2
from your_table
or
SELECT Column_1,Column_2
FROM YOUR_TABLE
GROUP BY Column_1,Column_2
CodePudding user response:
You can do SELECT distinct col2, col1 from (Table) GROUP BY 2