postgresql - Apply distinct in concat query -
i have written join query 3 tables, concatenating columns of these 3 tables. in last table keywords
column has 1 value while concatinating value repeated.
select g.goal_id, concat(coalesce(rk.keyword, ''), coalesce(gr.description, ''), coalesce(cd.keywords, '')) goal g left outer join resource_keyword rk on (g.creater_id = rk.refference_id , g.creater_id = :userid) left outer join groups gr on gr.creater_id = g.creater_id left outer join communication_detail cd on cd.party_id = gr.creater_id limit 5
actual result :
goal_id concat 296 nosedaily walk,sad,err 296 healthy goaldaily walk,sad,err 296 healthylife healthy daydaily walk,sad,err 296 tasty fooddaily walk,sad,err 296 healthygradedaily walk,sad,err
expected result :
goal_id concat 296 nosedaily walk,sad,err 296 healthy goaldaily walk 296 healthylife healthy daydaily walk 296 tasty fooddaily walk 296 healthygradedaily walk
here sad,err belong third table having 1 value separated commas, gets appended each , every row.
Comments
Post a Comment