Add Column on SQL server

2

I'm working on a system that needs to perform a sum that will be done in a SQL Server view. In C # I know how to solve this. I would like to resolve using SQL.

ColA    ColB
200911  1634,50
200911  558,29
200911  2446,66
200911  2860,90
200911  37905,01
200911  1238,11
200912  1634,50
200912  129191,82
200912  107644,42
200912  212634,97
200912  214817,55
200912  18754,56
200912  63911,39
200912  61991,81
201001  148,53
201001  17946,07
201001  1181,59
201001  108018,78
201001  3287,28
201001  191,17
201001  305,94

The result I need to get is this:

ColA    ColB
200911  46643,47
200912  810581,018
201001  131079,361

Does anyone have any ideas?

    
asked by anonymous 29.11.2014 / 22:36

1 answer

4

Use GROUP BY together with SUM()

SELECT ColA, SUM(ColB)
FROM tabela
GROUP BY ColA;
    
29.11.2014 / 23:03