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
create table user_stats ( user_id int, param varchar(64), value int ); insert into user_stats values (123, 'Won', 156), (123, 'Lose', 135); select user_id, sum(case when param = 'Won' then value else 0 end) 'Won', sum(case when param = 'Lose' then value else 0 end) 'Lose' from user_stats where param in ('Won', 'Lose') group by user_id;

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

Copy Clear