473,394 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Brick Codes

Hi,

I have a table of Locations around the country. My system produces reports
based on these Locations. I also have a table containing Brick Codes e.g.

Brick Post Code
AB51 AB51
AB52 AB52
AB55 AB55
AB56 AB56
AL01 AL1
AL02 AL2
AL03 AL3
AL04 AL4
How can I compare the first 3 or 4 letters of the postcode in the Locations
table to the corresponding entry in the Brick Codes table so I can add it to
my report?

Thanks for your help
Jul 20 '05 #1
2 3655
"Shaun" <no****@nospam.com> wrote in message
news:YL*******************@stones.force9.net...
Hi,

I have a table of Locations around the country. My system produces reports
based on these Locations. I also have a table containing Brick Codes e.g.

Brick Post Code
AB51 AB51
AB52 AB52
AB55 AB55
AB56 AB56
AL01 AL1
AL02 AL2
AL03 AL3
AL04 AL4
How can I compare the first 3 or 4 letters of the postcode in the Locations table to the corresponding entry in the Brick Codes table so I can add it to my report?

Use the substring function to get the n letters and the case
function to compare, such as ...

case when substring(brick,1,2) = substring([post code],1,2) then 'matching
1st 2' else 'no match' end "Comparison 1 of x",
case when substring(brick,1,3) = substring([post code],1,3) then 'matching
1st 3' else 'no match' end "Comparison 2 of x",
case when substring(brick,1,4) = substring([post code],1,4) then 'matching
1st 4' else 'no match' end "Comparison 3 of x",
etc

Jul 20 '05 #2
Shaun,

This is untested, but should do the trick.

WHERE Brick = CASE LEN(PostCode)
WHEN 3 THEN STUFF(PostCode,3,0,'0')
ELSE PostCode END

or

WHERE PostCode = CASE SUBSTRING(Brick,3,1)
WHEN '0' THEN STUFF(Brick,3,1,'')
ELSE Brick END
Hope that helps,
Rich
"Shaun" <no****@nospam.com> wrote in message
news:YL*******************@stones.force9.net...
Hi,

I have a table of Locations around the country. My system produces reports
based on these Locations. I also have a table containing Brick Codes e.g.

Brick Post Code
AB51 AB51
AB52 AB52
AB55 AB55
AB56 AB56
AL01 AL1
AL02 AL2
AL03 AL3
AL04 AL4
How can I compare the first 3 or 4 letters of the postcode in the Locations table to the corresponding entry in the Brick Codes table so I can add it to my report?

Thanks for your help

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Shane Groff | last post by:
I know this is a recurring discussion (I've spent the last 3 days reading through threads on the topic), but I feel compelled to start it up again. After reading through the existing threads, I...
6
by: Josh Mcfarlane | last post by:
I keep trying to get myself out of the return-code mindset, but it doesn't seem to work. They are suppose to get rid of if-then statements of return codes, but you still have to do an if statement...
2
by: Shaun | last post by:
Hi, I have a table of Locations around the country. My system produces reports based on these Locations. I also have a table containing Brick Codes e.g. Brick Post Code AB51 AB51 AB52 ...
18
by: Steve Litvack | last post by:
Hello, I have built an XMLDocument object instance and I get the following string when I examine the InnerXml property: <?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1...
3
by: c# beginner | last post by:
we are trying to standardize return codes across our .NET applications (that are soon to be developed.) What is the best practice for standardizing return codes? I know of only the following...
6
by: normunds | last post by:
hi! I'm newbie in css and I can't make myself brick boxes that work in IE and Firefox. The problem is in brick size and layout. Can anybody put there code, how to make such wall without absolute...
3
by: PerlPhi | last post by:
hi! i have a Perl code in here that when ran the program accepts any Perl codes from the user input (<STDIN>, of course use no syntax errors), then after breaking the multiline input, the inputs will...
5
by: =?GB2312?B?17/HvyBaaHVvLCBRaWFuZw==?= | last post by:
Hi, I would like to have someone comments on what's the best practice defining error codes in C. Here's what I think: solution A: using enum pros: type safe. better for debug (some debugger...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.