clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 1044276 fiddles created (9440 in the last week).

;WITH personFruits AS ( SELECT 'John' AS [Person], 'Apple' AS [Fruit] UNION SELECT 'John' AS [Person], 'Banana' AS [Fruit] UNION SELECT 'John' AS [Person], 'Kiwi' AS [Fruit] UNION SELECT 'Jane' AS [Person], 'Apple' AS [Fruit] UNION SELECT 'Jane' AS [Person], 'Strawberry' AS [Fruit] UNION SELECT 'Jane' AS [Person], 'Watermellon' AS [Fruit] UNION SELECT 'Jane' AS [Person], 'Grape' AS [Fruit] UNION SELECT 'Dale' AS [Person], 'Kiwi' AS [Fruit] UNION SELECT 'Dale' AS [Person], 'Watermellon' AS [Fruit] ) SELECT p.Person ,STRING_AGG(p.Fruit, ', ') WITHIN GROUP (ORDER BY p.Fruit) AS [FruitsWithComma] ,STRING_AGG(p.Fruit, '; ') WITHIN GROUP (ORDER BY p.Fruit) AS [FruitsWithSemicolon] ,STRING_AGG(p.Fruit, ' - ') WITHIN GROUP (ORDER BY p.Fruit) AS [FruitsWithDash] FROM personFruits AS p GROUP BY p.Person ORDER BY p.Person
Person FruitsWithComma FruitsWithSemicolon FruitsWithDash
Dale Kiwi, Watermellon Kiwi, Watermellon Kiwi, Watermellon
Jane Apple, Grape, Strawberry, Watermellon Apple, Grape, Strawberry, Watermellon Apple, Grape, Strawberry, Watermellon
John Apple, Banana, Kiwi Apple, Banana, Kiwi Apple, Banana, Kiwi
 hidden batch(es)


;WITH personFruits AS ( SELECT 'John' AS [Person], 'Apple' AS [Fruit] UNION SELECT 'John' AS [Person], 'Banana' AS [Fruit] UNION SELECT 'John' AS [Person], 'Kiwi' AS [Fruit] UNION SELECT 'Jane' AS [Person], 'Apple' AS [Fruit] UNION SELECT 'Jane' AS [Person], 'Strawberry' AS [Fruit] UNION SELECT 'Jane' AS [Person], 'Watermellon' AS [Fruit] UNION SELECT 'Jane' AS [Person], 'Grape' AS [Fruit] UNION SELECT 'Dale' AS [Person], 'Kiwi' AS [Fruit] UNION SELECT 'Dale' AS [Person], 'Watermellon' AS [Fruit] ) SELECT p.Person ,STRING_AGG(p.Fruit, ', ') WITHIN GROUP (ORDER BY p.Fruit) AS [FruitsWithComma] ,STRING_AGG(''+p.Fruit, '; ') WITHIN GROUP (ORDER BY p.Fruit) AS [FruitsWithSemicolon] ,STRING_AGG('' + '' + p.Fruit, ' - ') WITHIN GROUP (ORDER BY p.Fruit) AS [FruitsWithDash] FROM personFruits AS p GROUP BY p.Person ORDER BY p.Person
Person FruitsWithComma FruitsWithSemicolon FruitsWithDash
Dale Kiwi, Watermellon Kiwi; Watermellon Kiwi - Watermellon
Jane Apple, Grape, Strawberry, Watermellon Apple; Grape; Strawberry; Watermellon Apple - Grape - Strawberry - Watermellon
John Apple, Banana, Kiwi Apple; Banana; Kiwi Apple - Banana - Kiwi
 hidden batch(es)