Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
with -- ΠΏΠ°ΠΊΠ΅Ρ‚Ρ‹ p as ( select 3 as cnt from dual union all select 2 as cnt from dual union all select 5 as cnt from dual union all select 2 as cnt from dual union all select 1 as cnt from dual ), -- Π±ΡƒΡ‚Ρ‹Π»ΠΊΠΈ b as ( select level as num from dual where 0 > 0 connect by level <= 11 ) -- ΠΏΠ°ΠΊΠ΅Ρ‚Ρ‹ с ΠΏΠΎΠΌΠ΅ΡΡ‚ΠΈΠ²ΡˆΠΈΠΌΠΈΡΡ Π±ΡƒΡ‚Ρ‹Π»ΠΊΠ°ΠΌΠΈ select 'Π’ΠΌΠ΅ΡΡ‚ΠΈΠΌΠΎΡΡ‚ΡŒ '||c2.pack_cnt as pack, listagg(c2.bottle_num,', ') within group (order by c2.bottle_num) as bottles from ( -- Π±ΡƒΡ‚Ρ‹Π»ΠΊΠΈ Π½Π° мСстах Π² ΠΏΠ°ΠΊΠ΅Ρ‚Π°Ρ… select c1.*, -- сопоставляСм мСсто Π² ΠΏΠ°ΠΊΠ΅Ρ‚Π΅ Π½ΠΎΠΌΠ΅Ρ€Ρƒ Π±ΡƒΡ‚Ρ‹Π»ΠΊΠΈ ΠΏΠΎ порядку (select bb.bottle_num from (select row_number() over (order by b.num) as bottle_num from b) bb where bb.bottle_num = c1.pack_place) bottle_num from ( -- мСста Π² ΠΏΠ°ΠΊΠ΅Ρ‚Π°Ρ… select p.pack_num, p.pack_cnt, row_number() over (order by p.pack_num,d.n) as pack_place from (select row_number() over (order by p.cnt desc) as pack_num, p.cnt as pack_cnt from p) p, (select level as n from dual connect by level <= (select max(p.cnt) from p)) d where d.n <= p.pack_cnt order by p.pack_num,d.n )c1 )c2 group by c2.pack_num,c2.pack_cnt order by c2.pack_num;

Stuck with a problem? Got Error? Ask AI support!

Copy Clear