表一的aid对应表二的多条记录
表1
cid aid startdate
6128 1472583691 2017-03-27
6128 2147483647 2017-03-27
表二
id number cid money account updatetime
1 20170324163556 6128 5600 2147483647 2017-03-24 16:36:27
4 20170325134338 6128 5000 2147483647 2017-03-25 13:43:52
5 20170327200429 6128 2000 1472583691 2017-03-27 20:04:44
6 20170327201038 6128 6000 2147483647 2017-03-27 20:10:49
求总和?排序?你能说的再具体点吗?
select sum(t.money),t.aid,t.startdate from(select t1.aid,t1.startdate,t2.money from t2,t1
where t2.account=t1.aid) t
group by t.aid,t.startdate
order by t.startdate