SQLite Select data from multiple rows returned as one row

后端 未结 3 2058
半阙折子戏
半阙折子戏 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:04

    Doug's solution didn't work for me. The code below, however, did work for me but it's very slow...

    SELECT 
       a.ID, 
       a.Name AS Name1,
       (SELECT b.Name FROM Emp b 
                 WHERE b.ID = a.ID
                 AND b.Name != a.Name LIMIT 1) AS Name2
    FROM emp a 
    GROUP BY a.ID
    

提交回复
热议问题