I have done some searching and can see that this question has been asked several times before, but I can't seem to translate the solutions into my own working example. Can anyone point me in the right direction?
I have three database tables as below
People
+-------+------------+
| uid | person |
+-------+------------+
| 1 | Tom |
+-------+------------+
| 2 | Dick |
+-------+------------+
| 3 | Harry |
+-------+------------+
| 4 | Peter |
+-------+------------+
| 5 | Paul |
+-------+------------+
Sports
+---------+----------------+
| gid | group_name |
+---------+----------------+
| 1 | Dancing |
+---------+----------------+
| 2 | Golf |
+---------+----------------+
| 3 | Football |
+---------+----------------+
| 4 | Tennis |
+---------+----------------+
| 5 | Squash |
+---------+----------------+
Teams
+---------+---------+
| gid | uid |
+---------+---------+
| 1 | 1 |
+---------+---------+
| 2 | 1 |
+---------+---------+
| 3 | 1 |
+---------+---------+
| 1 | 2 |
+---------+---------+
| 2 | 2 |
+---------+---------+
| 3 | 2 |
+---------+---------+
| 4 | 2 |
+---------+---------+
| 2 | 3 |
+---------+---------+
| 1 | 4 |
+---------+---------+
| 5 | 4 |
+---------+---------+
| 1 | 5 |
+---------+---------+
| 4 | 5 |
+---------+---------+
| 3 | 5 |
+---------+---------+
I would like a SELECT query that returns one row per person listing all the sports they do (comma separated). In the example above, the results would be
+-------+------------+----------------------------------+
| uid | person | group_name |
+-------+------------+----------------------------------+
| 1 | Tom | Dancing, Golf, Football |
+-------+------------+----------------------------------+
| 2 | Dick | Dancing, Golf, Football, Tennis |
+-------+------------+----------------------------------+
| 3 | Harry | Golf |
+-------+------------+----------------------------------+
| 4 | Peter | Dancing, Squash |
+-------+------------+----------------------------------+
| 5 | Paul | Tennis, Football |
+-------+------------+----------------------------------+
In MYSQL, I would use GROUP_CONCAT, but in this instance I am using SQL SERVER.
Can anyone help please?