Home > Net >  MYSQL how to combine duplicate rows numbers into one row with all data
MYSQL how to combine duplicate rows numbers into one row with all data

Time:04-21

How do I combine duplicate rows from the same table into one row total affiche For example, if I have the following two rows:

| doc | grp | used
 h1     TC3  1.235
 h1     TC3  3.501
 h3     MR1  35
 h4     BB1  135
 h4     BB1  1.20
 

I want this affiche total in one row widout duplicate

| doc | grp | used
 h1     TC3  4.736
 h3     MR1  35
 h4     BB1  136.20

CodePudding user response:

select doc,
       grp,
       sum(used) as used 
from table 
group by 1,2 order by 1
  • Related