SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
select setseed(0.5); create table t as select (array['Вася', 'Олег', 'Петя'])[round(random() * 2 + 1)] as name, round(random() * 4 + 1) as grade from generate_series(1, 10000); /*Для всех участников(поле name) у кого больше 2 двоек(поле grade), надо вывести колличество пятёрок*/ explain analyze select name, count(*) filter(where grade = 5) from t group by name having count(*) filter(where grade = 2) > 2;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear