SQL query on SUM function plus JOINS
As I understand payment_id is unique (maybe primary). If so:

SELECT payment_id, SUM(amount), payment_date
FROM payment
WHERE payment_date &gt;= '2018-01-01' 
AND payment_date &lt;= NOW())
GROUP BY payment_id WITH ROLLUP;


If it is not unique, or if ONLY_FULL_GROUP_BY enabled:

SELECT payment_id, SUM(amount), payment_date
FROM payment
WHERE payment_date &gt;= '2018-01-01' 
AND payment_date &lt;= NOW())
GROUP BY payment_id, payment_date WITH ROLLUP
HAVING payment_date IS NOT NULL or payment_id IS NULL;


Last query will give wrong result if payment_date can be NULL.