Postgresql select multiple records from 2 tables with different number of columns -


i have 2 tables in postgres db following records -:

tablea ====== id       desc          team       status 254      nsw emp       sales        365      nsw,vic emp   sales        l 2345     nsw emp       post sales   ........... .....    tableb ====== id      state 254     nsw 365     nsw 365     vic 365     qld 2345    nt 2345    nsw ........... 

i want select id, desc, status , state 2 tables each unique id , capture output in following format.

id       desc        status      state 254      nsw emp                nsw 365      nsw,vic emp   l          nsw,vic,qld 2345     nsw emp                nt,nsw ......... 

attempted use select statements join/intersect , select array(....... fails "each intersect querymust have same number of columns"

any ideas appreciated ?

select tablea.id,        descr,        team,        status,        array_agg(state)         tablea          inner join tableb           on tablea.id = tableb.id         group tablea.id,descr,team,status 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -