简体   繁体   中英

Select distinct values from multiple columns

I had a table (Some_Table) with two columns:
AB
-------------------
1 test
2 test
3 test1
4 test1

i would like to return DISTINCT values for column B and it's associated value in column A (first in distinct set), so something like this:

AB
-----------
1 test
3 test1

What is the sql?

select min(A),B
  from table
 group by B

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM