SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
SELECT IF(YEAR(p.payment_date) IS NULL, 'Total', YEAR(p.payment_date)) AS income_year, IF(s.staff_id IS NULL, 'Year total', CONCAT(s.last_name, ' ', s.first_name)) AS staff, SUM(p.amount) AS total_payments FROM payment p LEFT JOIN staff s ON p.staff_id = s.staff_id GROUP BY YEAR(p.payment_date), s.staff_id WITH ROLLUP;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear