typora教程
https://mp.weixin.qq.com/s/l24xeCQx08gi17Sxo8cUXg
SELECT
t1.id,
t1.user_id,
t2.total_balance
FROM
user_assets_details t1
LEFT JOIN (
SELECT
user_id,
DATE ( create_time ) AS DATE,
SUM( balance ) AS total_balance
FROM
user_assets_details
WHERE
DATE(create_time) = #{yearAgo}
GROUP BY
user_id
) AS t2 ON t1.user_id = t2.user_id WHERE DATE ( t1.create_time ) = #{yearAgo};