mysql - SQL: select records based on certain criteria, merging records that are duplicates -


i need sql statement derive list of rows unique.

given set of data, want result remove duplicate rows duplicate defined column1 being identical , column 2 , 3 empty

things:  id    column1    column2        column3 1                 z              4 2        b          y              7 3        b          m              9 4                                5         6                 z              4                        

expected result:

a, z, 4 b, y, 7 b, m, 9 a,  ,  a, z, 4 

note a, z, 4 appears twice in result , correct. rows merged when column1 same , column2 , column3 empty.

how construct query result?

using unique (and therefore non-group-able) id when it's non-null, , group-able null when it's null should work.

select column1, column2, column3 things group case when column1 null null else id end,     case when column2 null null else id end,     case when column3 null null else id end 

Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -