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... :confused:
Printable View
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... :confused:
Try the MS SQL forum.
FK
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)