Oracle SQL : Using NVL(), LENGTH(), UPPER()

Here is the case:

Create a query that displays the city names, country codes and state province names, but only for those cities that start on S and have at least 8 characters in their name. If city does not have province name assigned, then put Unknown Province.

Here is the solution:

SELECT city, country_ID, NVL(state_province, 'Unknown Province') "PROVINCE" 
WHERE (city LIKE UPPER('s%') and LENGTH(city)    >=   8  )

Have fun!

About Anatoly Spektor

My name is Anatoly Spektor (originally Anatolijs Spektors) I am Software and Web Developer. I have worked in Seneca Center for Development of Open Technology on Big Blue Button Add-on - Polling Module, Red Hat and some other places :) I am an author of the book 'Eclipse Debugging How To', Muay Thai fighter and amateur photographer ;)
This entry was posted in Database, ORACLE, SQL and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s