【求SQL语句】MySql数据库中字段值相加的问题
时间:2011-08-19
来源:互联网
userId money date
1 500 2011-08-09
2 100 2011-08-12
1 200 2011-08-17
1 300 2011-08-18
如上表:
求MySql语句一条, 要求:在日期范围内,相同userId的money相加,
例如: 2011-08-09 ~ 2011-08-18 内,userId 为 1 的用户总的 money 相加为 1000 .
1 500 2011-08-09
2 100 2011-08-12
1 200 2011-08-17
1 300 2011-08-18
如上表:
求MySql语句一条, 要求:在日期范围内,相同userId的money相加,
例如: 2011-08-09 ~ 2011-08-18 内,userId 为 1 的用户总的 money 相加为 1000 .
作者: laughing__ 发布时间: 2011-08-19
select userId ,sum(money) from tt where `date` between '2011-08-09' and '2011-08-18'
group by userId
group by userId
作者: wwwwb 发布时间: 2011-08-19
SQL code
select sum(userid),sum(money) from tb where date between '' and ''
作者: rucypli 发布时间: 2011-08-19
select userid,sum(money) from er where er.date between '2010-10-01' and '2010-11-10' group by userid
作者: sunjiaohunbegfly 发布时间: 2011-08-19
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28