U
U
udi2014-04-15 14:16:09
MySQL
udi, 2014-04-15 14:16:09

How to remove SQlite duplicates with gluing data by columns?

Tell me a query that can remove duplicates in one column by gluing information in other columns.
For example, there is a table

col1  col2  col3  col4  col5
str1   1     1     -     -
str1   -     -     1      1

It is necessary that the data be converted into one line of the type
str1 1 1 1 1
. If there is data in both lines, then they must be summed up. for example
col1  col2  col3  col4  col5
str1   1     1     -      -
str1   1     1     -      1

will turn into
str1 2 2 - 1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2014-04-15
@udi

select col1, sum(col2), sum(col3), sum(col4), sum(col5)
from 'tweedledum'
group by col1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question