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

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

android - How to create dynamically Fragment pager adapter -