goofy78270
Technical User
I am trying to list each distinct state and county with a comma deliminated field for all zipcodes within that county and state. I have the following code, but it seems to combine all zipcodes within the table and not the ones related to the state and county.
Code:
DECLARE @ZipCode varchar(1000)
Select @ZipCode = COALESCE(@ZipCode + ', ', '') +
CAST(zip AS varchar(5))
FROM empower.ZIPCODES
Select distinct State, County, @ZipCode
From empower.ZIPCODES
order by state, county