Answer the question
In order to leave comments, you need to log in
How to group by 2 columns separately?
CREATE VIEW bux_filter AS
SELECT id_orugie_p AS 'id orugie', SUM(cena) AS 'sum cena orugie' FROM postavki_filter
GROUP BY id_orugie_p
UNION ALL
SELECT id_pos_p AS 'id post', SUM(cena) AS 'sum cena post' FROM postavki_filter
GROUP BY id_pos_p
Answer the question
In order to leave comments, you need to log in
Agree that you want the strange, but even strange things can be solved. For example row_number and full join
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;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question