Last active
February 2, 2020 14:55
-
-
Save alevyinroc/b48ddc6b727654894aed2e00f1d3d8f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Original | |
| SELECT DISTINCT location | |
| ,stuff(( | |
| SELECT ',' + cast(a2.npa AS CHAR(3)) | |
| FROM areacodes a2 | |
| WHERE a2.location = a.location | |
| FOR XML PATH('') | |
| ), 1, 1, N'') AS areacodes | |
| FROM areacodes a | |
| ORDER BY location; | |
| -- 2017 Edition | |
| SELECT location | |
| ,string_agg(npa, ',') AS AreaCodes | |
| FROM areacodes | |
| GROUP BY location | |
| ORDER BY location; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment