SQLite Select data from multiple rows returned as one row

后端 未结 3 2081
半阙折子戏
半阙折子戏 2020-12-30 17:56

I would like to know whether it is possible to use a SELECT statement in SQLite to merge the data from two rows into one, similar to how is suggested in the SQL Server forum

3条回答
  •  无人及你
    2020-12-30 18:13

    SELECT 
       a.ID, 
       COALESCE(a.Name,'') as "Name-1", 
       COALESCE((SELECT b.Name FROM Emp b 
                 WHERE b.ID = a.ID
                 AND b.rowid != a.rowid LIMIT 1),'') as "Name-2"
    FROM emp a 
    GROUP BY a.ID
    

提交回复
热议问题