Hello All,
I am doing some data extraction from a database table: custtable. The customers have zip codes of 9 digits however I just need the first five of them. I am not sure of the syntax. Can anyone suggest me on this one?
This is what my statement is
where ((len (ct.zipcode ) > 5 and ct.country = '001')or ct.country <> '001')
This one returns customers with zipcodes > 5 and I need to only truncate this, coz my database also contains cust with zip code of only 5 digits and I have extracted that data already. Now I need all the zipcodes that have a length of 9 to be truncted to 5.
An earliest possible response is highly appreciable.
Thanks,
Rashi
Hello Rashi,
Try this:
select left(ct.zipcode, 5)
where ((len (ct.zipcode ) > 5 and ct.country = '001')or ct.country <> '001')
Hope this helps.
Jarret
|||useless post|||Even for T-SQL, it's still is
SELECT LEFT(postal_code, 5)
FROM AddressTable
Shouldn't need to, but if you want to trim it - RTRIM(LTRIM(LEFT(postal_code,5)))
No comments:
Post a Comment