图中a列对应多个c列,想要获取a列对应的c列的总和,然后b列正常显示,比如对应的c列总和是300,那么a列的每个值后面都显示300
MySQL有一种写法,你参考一下:
SELECT a, b, c, SUM(c) OVER (PARTITION BY a, b, c)
FROM Tab
GROUP BY 1,2,3
select t1.a,t1.b,t2.nc from 表 t1
left join
(select a,sum(c) as nc from 表 group by a) t2 on t1.a=t2.a
用开窗函数
select a,b,c,sum(c) over(partition by a) from 表