-
Post Code / Zip Code Query in SQL Enterprise Manager
I am trying to group individuals by the Post Code area that they live in.
In the UK, postcodes can be:
OL10 4PZ
M1 4AA
I want to group by the area up until the Space.. ie:
OL10
M1
Any help would be gratefully received...
-
-
Use Charindex() to find the position of the space and then use Left() to find everything up to the space.
Select Left(PostCode, CharIndex(' ', PostCode) - 1) As PostCodeArea
From MyTable
Group By Left(PostCode, CharIndex(' ', PostCode) - 1)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|