SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table halls ( id serial primary key, name text, seets_count int, screen_type text check (screen_type in ('regular', 'stereo')) ); insert into halls (name, seets_count, screen_type) values ('Blue', 25, 'regular'); insert into halls (name, seets_count, screen_type) values ('Gold', 15, 'stereo'); insert into halls (name, seets_count, screen_type) values ('Gray', 35, 'regular'); insert into halls (name, seets_count, screen_type) values ('Blue', 2, 'stereo'); select * from halls; select "name", "seets_count", "screen_type" from halls where "seets_count" < 20; SELECT "name", "seets_count", "screen_type" FROM ( SELECT "name", "seets_count", "screen_type" RANK() OVER (PARTITION BY "name" ORDER BY "seets_count" DESC) as "rank" FROM halls ) as m WHERE "rank" = 3 ORDER BY name ASC;
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear