大家好,请帮助我,
我有问题,我想从数据库postgreesql中获取数据
数据库架构:认证名称:au_accreditation
此数据库表
unit_code unit_score
1 3
1 3
1 4
1 4
2 1
2 3
2 3
2 5
所以,我想基于单位代码对每个数据求和,这样我就可以得到表数据了
unit_code unit_score
1 14 -> sum unit score from unit code : 1
2 12 -> sum unit score from unit code : 2
select
unit_code,
sum(CAST(unit_score AS int)) as unit_score
From <table>
group by unit_code