mysql - SQL: get unique rows based on concatenation of two columns -
i need sql statement derive list of rows unique based on concatenation of 2 columns.
given set of data, want result remove duplicate rows duplicate defined concatenation of column1 , column2.
things:
id column1 column2 column3 1 z l 2 b y g 3 b y g 4 y h 5 z l
this came with:
select distinct ( column1 || column2 ) things
result:
az ay
this works fine, derives list of unique concatenation of column1 , column2,
i need column3 returned well, in:
column1 column2 column3 z l b y g y h
this not work:
select distinct ( column1 || column2 ), column3 things
as returns more rows needed.
how construct sql statement derive desired result of unique rows based on concatenation of 2 columns? not matter if column3 not unique.
if not care values of column3
how come, can use group by
select column1, column2, column3 things group column1,column2
Comments
Post a Comment