如何将同一个表中的重复行合并为一行?例如,如果我有以下两行:
| doc | grp | used h1 TC3 1.235 h1 TC3 3.501 h3 MR1 35 h4 BB1 135 h4 BB1 1.20
我希望这一个非正式合计在一行中,不要重复
| doc | grp | used h1 TC3 4.736 h3 MR1 35 h4 BB1 136.20
avkwfej41#
select doc, grp, sum(used) as used from table group by 1,2 order by 1
1条答案
按热度按时间avkwfej41#