SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table test (id serial, email varchar, price int, type varchar, areaid int); insert into test (email, price, type, areaid) values ('person2@test1.com', 70, 'type1', 1), ('person3@test2.com', 60, 'type2', 2), ('person3@test3.com', 50, 'type1', 3), ('person4@test4.com', 110, 'type1', 3), ('person1@test1.com', 90, 'type2', 4), ('person2@test2.com', 65, 'type2', 1), ('person3@test3.com', 84, 'type2', 2), ('person4@test4.com', 84, 'type1', 2); Select b.email from test b group by b.email having 'type2'= any(array_agg(b.type)) and array_length(array_agg(b.type))=1;
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear