April 11, 2008 at 1:17 pm
Table A
--------
Country Code
Ind 320100
Eur 320200
Rus 320300
Sca 320400
Table B
--------
SubCode Country
201 Ind
202 Eur
203 Rus
204 Sca
I need to bring the output as below, by matching the subcode in Table B with that of Table A. Apparently if you take code 3"201"00 in Table A, subcode is 201 in TableB should match.
Country Code
Ind 320100
Eur 320200
Rus 320300
Sca 320400
April 11, 2008 at 1:52 pm
It appears that the SubCode appears in the same location each time in the Code value. I would think this would be pretty easy to do something like this
SELECT A.COUNTRY, A.CODE FROM TABLE A AS A
JOIN TABLE B AS B ON SUBSTRING(A.CODE, 2, 3) = B.SUBCODE
As long as the SubCode appears in the same location within the code string it should work.
Regards, Irish
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply