Click here to Skip to main content
15,671,597 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have data in table as below manner
Monthno m1    m2   m3
1       1     0    0
1       0     1    0
1       0     0    1
2       1     0    0
2       0     1    0

And I want change these data into look like below manner. Monthno column continues as same numbers and changed number will be inserted in same row again as new row
Monthno m1  m2     m3
1       1    1     1
2       1    1     0

[edit]Tabs to spaces for proper indentation[/edit]
[edit]Code block added - OriginalGriff[/edit]
Updated 14-Oct-14 3:03am

1 solution

SELECT MonthNo, SUM(M1) AS M1, SUM(M2) AS M2, SUM M3 AS M3 
FROM MyTable
Share this answer
OriginalGriff 14-Oct-14 9:16am    
Then you need to explain exactly what comprises "correct data" - we can't read your mind from here!
Burning Thoughts 14-Oct-14 9:17am    
thank you its working .....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900