1,账单表结构
id money create_date 1 10 2016-11-11 2 20 2016-11-12
2,需求是按日期排序,查询总金额<=1000元的账单列表数据
光阴似箭催人老,日月如移越少年。
select t.sum_money,t.date from (sum(money) as sum_money,create_date as date from tablename group by create_date) t order by t.date;
お金が合計金額の場合、SELECT id, Money, create_date FROM TABLE WHERE Money ORDER BY create_date DESC
select sum(money) sums,create_date from talbe group by create_date having sums<=1000 order by create_date;
select t.sum_money,t.date from (sum(money) as sum_money,create_date as date from tablename group by create_date) t order by t.date;
お金が合計金額の場合、
SELECT id, Money, create_date
FROM TABLE
WHERE Money ORDER BY create_date DESC
select sum(money) sums,create_date from talbe group by create_date having sums<=1000 order by create_date;