mysql 一张表做查询,求出一个字段的总和及按年份求出的总和,,急!!!

年份是当前年,要用一条语句

第1个回答  2015-09-29
SELECT SUM(payment_alreadyprice) FROM property_payment WHERE year(payment_time) = year(curdate())追问

修改后执行只有一个值,,,1200,还缺个全部的数量,可以放到一起吗?

追答

SELECT SUM(payment_alreadyprice) as currentYearNum,(SELECT SUM(payment_alreadyprice) FROM property_payment) as allYearNum FROM property_payment WHERE year(payment_time) = year(curdate())

或者

SELECT SUM(payment_alreadyprice) FROM property_payment WHERE year(payment_time) = year(curdate())
union all
SELECT SUM(payment_alreadyprice) FROM property_payment

第二条语句需要用一个list来接收

本回答被提问者采纳
相似回答