只要能用多条 SQL语句写的,就可以用一条写。
笨办法
select (select sum(amount) from tb where uid='xxx' and d>='2015-05-01' and d<='2015-05-31') as 上一个月,
(select sum(amount) from tb where uid='xxx' and d>='2015-06-01' and d<='2015-06-30') as 本月的,
(select sum(amount) from tb where uid='xxx' ) as 总金额
如果你有一个人员表的可以用人员表做left join
SELECT Count(uid),Count(amount),Count(d) FROM 表名;COUNT()是专门统计数据个数的。