Hi all,
I'm trying to create a column that contains all cities of the referenced addresses.
DECLARE @AddressList nvarchar(max)
SELECT @AddressList = COALESCE(@AddressList + ' ', '') + City FROM [Address]
SELECT
Employee.*,
(SELECT @AddressList) AS AddressCities
FROM Employee
But I dont know where to put the WHERE clause.
...
(SELECT @AddressList WHERE EmployeeId = Employee.EmployeeId) AS AddressCities
...
The above test doesnt work..
Table schemas are:
Employee
EmployeeId
NameAddress
Street
City
EmployeeId