Looping through a table and adding a column

I need some assistance with the sql to accomplish the desired outcome.  
Here is an example of what the data could look like in the table.
Table X
   L_ID                        C_ID          Indem
 32566                      54345        25.00
 32566                      54346       26.00
 32566                      54346        37.00
 32566                      54347         45.00

I will be writing this data to another table.  What I will be doing is taking everthing from the specified table X with the same L_ID and inserting it into another table.  The one thing that will change is that I need to add the Indem column when the C_ID is equal to another C_ID.  So with that said the C_ID with 54346  will need to have their Indem values added together and inserted into table Y.  
Who is Participating?
Kyle AbrahamsConnect With a Mentor Senior .Net DeveloperCommented:
insert into to_table select l_ID, C_ID, sum(indem) from  from_table group by l_id, c_id
oak29Author Commented:
Thanks!  Wow, that was a lot easier than I made it out to be.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.