SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table complex ( class int, price int ); insert into complex values (1, 100), (1, 103),(1, 110),(1, 104),(1, 109), (2, 200), (2, 203),(2, 220),(2, 204),(2, 209), (3, 300), (3, 303),(3, 330),(3, 304),(3, 309); select class, price from ( select class, price, row_number() over (partition by class order by price) rn from complex ) prices where (class=1 and rn < 3) -- 2 econom or (class=2 and rn < 4) -- 3 comfort or (class=3 and rn < 2) -- 1 premium ;
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear