This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
SELECT SUBSTR( country, 1, INSTR(country, '-',1) - 1) as whatever from table
Joined: Jun 08, 2007
Thankyou very much, that works very well. It extracts the string before the hyphen, however sometimes it returns null for String that do not have a hyphen. Is there any way to avaoid getting null in the result set. So that I only get non null values?
Many thanks once again.
Joined: Jan 24, 2006
use the NVL function :
SELECT NVL( SUBSTR( country, 1, INSTR(country, '-',1) - 1), country) as whatever from table