请解决下面的sql查询 [英] Please solve below sql query

查看:91
本文介绍了请解决下面的sql查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表格数据如下:

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





我想要更改这些数据看起来像下面的方式。 Monthno列继续作为相同的数字,更改的数字将再次插入同一行作为新行



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]

添加了代码块 - OriginalGriff [/ edit]



[edit]Tabs to spaces for proper indentation[/edit]
[edit]Code block added - OriginalGriff[/edit]

推荐答案

尝试:

Try:
SELECT MonthNo, SUM(M1) AS M1, SUM(M2) AS M2, SUM M3 AS M3 
FROM MyTable
GROUP BY MonthNo


这篇关于请解决下面的sql查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆