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 pt as (select year(payment_date) income_year, concat(last_name, ' ', first_name) staff, sum(amount) total_paiments from payment P join staff S on P.staff_id=S.staff_id group by income_year, staff with rollup) select case when staff is null and income_year is null then 'Total' else income_year end income_year, case when staff is null and income_year is not null then 'Year total' else staff end staff, total_paiments from pt

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

Copy Clear