none
Group by and concatenate records in a string

    Question

  • I have a table which looks like

    URL, Date, ActivityType, TextValue

    My requirement is to first issue a query which groups the results by URL, Date and ActivityType

    Now I don't want to sum/count the text value. the records which match the above grouping should be converted into a comma separated string.

    The net output of query is 

    URL1, 01/01/2000, 1, "a, b, c, d"

    URL1, 01/02/2000,  2, "e, f, g, h"

    Here a, b, c, d, e, f, g h are values taken from the column TextValue and concatenated for the URL, Date and Activity Grouping.

    Edit: I saw some examples on concatenation using variables and coalesce function... but I don't know how to use in a group query because it expects aggregate functions for anything which is not a part of groupby... 


    MSDNStudent Knows not much!


    Saturday, March 31, 2012 9:16 AM

Answers

All replies