SQLite: group_concat() multiple columns

前端 未结 1 1826
無奈伤痛
無奈伤痛 2021-02-02 18:23

I has a problem:

In my SQLite (sqlite3 on android) database I have a table like so

company |  name    | job
--------------------------
      1 |  \'Peter         


        
相关标签:
1条回答
  • 2021-02-02 18:33

    You were close!

    SELECT 
        company,
        group_concat(concat) AS formated
    FROM (
        SELECT
            company,
            CASE 
                WHEN job IS NULL THEN name
                ELSE name || ' (' || job || ')'
            END AS concat
        FROM jobs
    )
    GROUP BY company
    
    0 讨论(0)
提交回复
热议问题