sql - How can multiple rows into a single line? -
i have query 1 table returns multiple rows. combine these 1 row each person.
is there way this?
example data query , result need:
use grouping , aggregates:
select max(seq) seq, id, sum(red1) red1, sum(red2) red2, sum(red3) red3, sum(green1) green1, sum(green2) green2, sum(green3) green3 table 1 group id
demo: http://sqlfiddle.com/#!4/ad36e/3
note: use different aggregates values depending on result want if field has more 1 non-null value in group. using sum
gives sum of values in group, using max
gives highest value in group.
Comments
Post a Comment