Jump to content

sum rows based on condition


rony_78

Recommended Posts

hello friends
I have a table with three columns col1,col2 and col3. how do I add rows based on column1?
col1|col2|col3|
A | 2 | 4 |
B | 6 | 8 |
A | 10 |12|
C | 14 |16|
C | 3 | 2 |
Output
col1 col2 col3
----|-------|-------|
A | 12 | 16|
B | 6 | 8|
C | 17 |18|

I am running the query in ms access from vb.net, can someone tell me why it does not work

select col1, SUM(col2) as col2, SUM(col3) as col3  from table1  group by col1

Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...