I got the following exercices: Determine the average distance for all addresses, and concat the average distances by address in a csv like column “CSV_Avg” as can be seen in table Address _Distances.
This is how the table looks
This is what query should do
So far i've done this but i can't find a way how to concatenate all rows in a single column
This is how my query looks like
SELECT DISTINCT
[id_address]
,sum([distance])/count([distance]) as "AVGDistance"
,CONCAT([id_address],'=',[distance]) as "CSV_AVG"
FROM [Test].[dbo].[View_2]
WHERE [id_address] IS NOT NULL
Group by [id_address],[distance]