Help! How to Truncate, Cut off, strip end off a Whole , Real number?
454460Sep 15 2005 — edited Sep 16 2005Hi I am new to SQL-Oracle stuff and i have been searching in huge books and web to find out how to cut off the end numbers of a real whole number not a decimal number.
I have a table that has zip codes listed in one of the columns, but many of the zip codes contain more than 5 numbers in them. I am trying to get SQL to show me the same column of number but listing only the first 5 numbers in the zip code.
I intend to compare this first column of zip codes with another column of zip codes in a second different table, were all the zip codes in the second table already only have 5 digits. So I am trying to get the SQL to list the zip codes in the first table to show only the 5 first numbers of zip code so that i can compare the two tables zip code columns.
I have tried the TRUNC command but that only works for decimals and none of the zip code numbers have decimal places.
SELECT ZIP TRUNC(ZIP, 5) FROM ADDRESS;
So how do I cut off the extra numbers i dont want? example:
zip code: 802061116 how do i get rid of the last four digits and just show me the 80206 part? It seems there probably is a very simple way to do it but none of the info i came across talks about it.
any help much appreciated.