sql - Get non duplicates of column x but duplicates of column y -


i have table (call table mytable).

it has data this:

number / name

1    jake 2    chris 3    sally 4    billy 1    tom 5    cathy 

(i realize poor setup, didn't luxury of doing setup)



i need query table results returned with:

1    jake 2    chris 3    sally 4    billy 5    cathy 

or

2    chris 3    sally 4    billy 1    tom 5    cathy 


it not matter name gets returned duplicated number... 1 gets returned.

here not-working attempt:

with (       select number       mytable ),  b (       select number, name       mytable )   select a."number", b."name"  left join b on a."number" = b."number" 

use group by ensure each number returned once, , use aggregate function pick 1 of values name:

select number, max(name) name yourtable group number 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -