Jump to content
We've recently updated our Privacy Statement, available here ×

DerekGannaway

Members
  • Posts

    2
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Posts posted by DerekGannaway

  1. In your query you can use the GROUP_CONCAT function and GROUP BY the field you don't want duplicated to achieve that result. Here's an example table with duplicated data:

     

    StateCity
    New YorkNew York City
    New YorkSyracuse
    CaliforniaLos Angeles
    CaliforniaSan Francisco
    TexasAustin

     

    With the below query

    SELECT state, GROUP_CONCAT(city SEPARATOR ", ") AS cities FROM table GROUP BY state[/code]

    The data will now be displayed as

    statecities
    New YorkNew York City, Syracuse
    CaliforniaLos Angeles, San Francisco
    TexasAustin

     

    You can also sort the cities or remove duplicates from that field as well with additional functions inside the GROUP_CONCAT. More information about GROUP_CONCAT can be found at https://dev.mysql.com/doc/refman/8.0/en/group-by-functions.html#function_group-concat

     

     

×
×
  • Create New...