我可以用逗号将多个行分隔成一个列吗?
[TicketID], [Person] T0001 Alice T0001 Bob T0002 Catherine T0002 Doug T0003 Elaine
[TicketID], [People] T0001 Alice, Bob T0002 Catherine, Doug T0003 Elaine
GROUP_CONCAT
编辑:
DECLARE @Tickets TABLE ( [TicketID] char(5) NOT NULL, [Person] nvarchar(15) NOT NULL)INSERT INTO @Tickets VALUES ('T0001', 'Alice'), ('T0001', 'Bob'), ('T0002', 'Catherine'), ('T0002', 'Doug'), ('T0003', 'Elaine')SELECT * FROM @Tickets
烙印99
largeQ
守着一只汪
相关分类