文章详情页
mysql如何查询累加金额等于某个值的所有数据?
浏览:232日期:2022-06-16 16:50:33
问题描述
1,账单表结构
id money create_date1 102016-11-112 202016-11-12
2,需求是按日期排序,查询总金额<=1000元的账单列表数据
问题解答
回答1:select t.sum_money,t.date from (select sum(money) as sum_money,create_date as date from tablename group by create_date) t order by t.date;
回答2:若money为总金额,则SELECT id, money, create_date FROM TABLE WHERE money <= 1000ORDER BY create_date DESC
回答3:select sum(money) sums,create_date from talbe group by create_date having sums<=1000 order by create_date;
相关文章:
1. angular.js - angularjs scope.$watch取不到input变化的值2. android glide asbitmap 在baseadpter中的问题3. docker网络端口映射,没有方便点的操作方法么?4. javascript - Angular2中声明的成员变量为何显示undefined?5. javascript - Android 的 webview 中怎么监听 url 的 hash 变化6. 使用未定义的常量user_id-假定为“user_id”7. 在别的电脑使用JDBC连接其他电脑上安装的mysql数据库8. mysql - thinkphp一个查询语句的实现9. mysql 欄位值移動10. 做一个抽奖系统
排行榜

网公网安备