0

How can I group (by) two joined tables (in an Oracle database) like this:

cant:
id      CANT_VAL    COD_VAL fk_id_chest
18059   18.56       R12     1
18060   11          R10     2
18061   15          R11     3

col:
FK_ID_COL_DMA   CANT_VAL    COD_VAL
18059           1134        R10
18059           1234        R3
18061           1111        R5

to look like that:

id      CANT_VAL    COD_VAL    fk_id_chest
18059   18.56       R12        1
18059   1134        R10        1
18059   1234        R3         1
18060   11          R10        2
18061   15          R11        3
18061   1111        R5         3

fk_id_chest is a "link" to another table that I need in the final result. Thanks!

0

I found my answer, thanks!

select cant.id,CANT.CANT_VAL,CANT.COD_VAL,CANT.FK_ID_CHEST from cant
union
select COL.FK_ID_COL_DMA,COL.CANT_VAL,COL.COD_VAL,CANT.FK_ID_CHEST from col 
    inner join cant
        on cant.id=COL.FK_ID_COL_DMA

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.