SQL query to add some data from the table

I have a table. I need a SQL query to add some data from the table (MOTcalculation). I need a select query or a make table query. I need to add for every CNP and to do this automaticaly because I have more than 250 CNP. Please see the example!

MOTcalculation                                                 Query
ID      CNP      TotalMOT                      ID          CNP         TotalMOT
1         N1            15                            1             N1            22
2         C1             3                             2             C1            10
3         D3             6                             3             D3              6
4         C1             7                             4             O2            18
5         N1             4
6         N1             3
7         O2             9
8         O2             9    

Thank you!
Qw MAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

select row_number() OVER (ORDER BY cnp), cnp, sum(TotalMOT) from MOTCalculation group by cnp

Open in new window

Qw MAuthor Commented:
It is not working! Please see the attachment!
Jon von der HeydenCourse Leader & Managing DirectorCommented:
Select query should be fine:
SELECT MOTCalculation.CNP, Sum(MOTCalculation.TotalMOT) AS SumOfTotalMOT
FROM MOTCalculation
GROUP BY MOTCalculation.CNP;

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Qw MAuthor Commented:
Thank you JONvdHeyden!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.