Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
with cte as( SELECT YEAR(p.payment_date) AS income_year, CONCAT(s.last_name, ' ', s.first_name) AS staff, SUM(p.amount) AS total_payments FROM payment p JOIN staff s USING(staff_id) GROUP BY income_year, staff WITH ROLLUP) SELECT IFNULL(cte.income_year,'Total') AS income_year, IFNULL(cte.staff,'Year total') AS staff, cte.total_payments FROM cte

Stuck with a problem? Got Error? Ask AI support!

Copy Clear