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
CREATE TABLE test ( id_orugie_p int, id_pos_p int, cena int ); INSERT INTO test VALUES (1, 1, 13),(3, 2, 15),(4, 3, 16),(6, 4, 13),(6, 5, 10); SELECT orugie, sum_cena_orugie, pos, sum_cena_pos FROM ( SELECT row_number() over (order by id_orugie_p) orugie_rn, id_orugie_p orugie, SUM(cena) sum_cena_orugie FROM test GROUP BY id_orugie_p ) t_orugie FULL JOIN ( SELECT row_number() over (order by id_pos_p) pos_rn, id_pos_p pos, SUM(cena) sum_cena_pos FROM test GROUP BY id_pos_p ) t_pos on orugie_rn = pos_rn;

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

Copy Clear