I have a table 'booking' like this:
booking_id,
date,
client,
sponsor
I'm trying to get a monthly summary:
SELECT
MONTH(date) AS M,
Sponsor,
Client,
COUNT(booking_id) AS c
FROM booking
GROUP BY
M, Sponsor, Client
Now I want to see at which dates the client made bookings. I tried using STUFF() (referenced in this post: Simulating group_concat MySQL function in Microsoft SQL Server 2005?) but it conflicts with the group-by statement.
Sample data as per request. Currently i have the following:
M Sponsor Client c
March AB y 3
March FE x 4
April AB x 2
Desired output:
M Sponsor Client c dates
March AB y 3 12, 15, 18
March FE x 4 16, 19, 20, 21
April AB x 2 4, 8
Where the numbers are the day-numers (e.g. 12 march, 15 march, 18 march). In mysql I would use group_concat(date) to get the last column.
Big kudos for the answer :-)