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 tmp AS ( SELECT YEAR(payment_date) AS income_year, CONCAT(last_name, ' ',first_name) AS staff, SUM(amount) AS total_paiments, GROUPING(YEAR(payment_date)) as gr FROM payment p JOIN staff s ON p.staff_id = s.staff_id GROUP BY income_year, staff WITH ROLLUP ) SELECT COALESCE(income_year, 'Total') AS income_year, COALESCE(staff, 'Year total', '') AS staff, total_paiments, gr FROM tmp

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

Copy Clear