SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table payments ( pay_type int, price int, created_id int ); insert into payments values (0, 100, 123), (1, 101, 123), (0, 102, 321), (1, 103, 321), (1, 104, 321); create view PRICE as select created_id, sum(if(pay_type = 0, price, 0)) cash_amount, sum(if(pay_type = 1, price, 0)) card_amount from payments group by created_id; select * from PRICE
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear