Home > Back-end >  SQL - select sample values of column1 ofr each distinct value of column2
SQL - select sample values of column1 ofr each distinct value of column2

Time:12-17

I have a following table:

col1 col2
one a
two a
333 b
323 b

How do I get for each distinct value present in col2 only 1 corresponding value in col1 lie the following:

col1 col2
one a
323 b

CodePudding user response:

 select col2,min(col1)x
 from your_table
  group by col2;
  •  Tags:  
  • sql
  • Related