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:

http://upic.me/i/wf/stack.jpg

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

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -