SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table tbl (id int, price int); create table tbl2 (id2 int, name varchar(64)); insert into tbl2 values (1, 'svet'), (2, 'maxim'), (3, 'petr'), (4, 'maria'), (5, 'ivan'); insert into tbl values (1, 10),(1, 20), (2, 10),(2, 15),(2, 20),(2, 15), (3, 10),(3, 100), (4, 1),(4, 2),(4, 3), (5, 1010); SELECT tbl.id, tbl2.name, SUM(tbl.price) sum_price FROM tbl JOIN tbl2 ON tbl.id = tbl2.id2 GROUP BY tbl.id, tbl2.name HAVING SUM(price) > 100 ORDER BY sum_price DESC;
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear