| | |
I'm sure a very simple question....
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Nov 2006
Posts: 22
Reputation:
Solved Threads: 0
I have a school problem, I'm not going to try and hide it. This is for Oracle9i: SQL class. The question we have to write a code for is:
Create a list of customers that will display the characters 'NOT REFERRED' if the customer was not referred by another customer. The reffered column shows a number if reffered for example, 1204. I know I need to use TO_CHAR to change it to string and then NVL to put 'NOT REFERRED'. My quesiton is, if I run this, it gives me an error. I know how to do one at a time, but not together.
if i try adding NVL and (), I get 9999 and when I add 'NOT REFERRED' for my TO_CHAR, I get error:
SELECT INITCAP(lastname), INITCAP(firstname), TO_CHAR(NVL(referred, 'test'))
*
ERROR at line 1:
ORA-01722: invalid number
Any suggestions?
Create a list of customers that will display the characters 'NOT REFERRED' if the customer was not referred by another customer. The reffered column shows a number if reffered for example, 1204. I know I need to use TO_CHAR to change it to string and then NVL to put 'NOT REFERRED'. My quesiton is, if I run this, it gives me an error. I know how to do one at a time, but not together.
sql Syntax (Toggle Plain Text)
SELECT INITCAP(lastname), INITCAP(firstname), TO_CHAR(NVL(referred, 0009999)) FROM customers
if i try adding NVL and (), I get 9999 and when I add 'NOT REFERRED' for my TO_CHAR, I get error:
SELECT INITCAP(lastname), INITCAP(firstname), TO_CHAR(NVL(referred, 'test'))
*
ERROR at line 1:
ORA-01722: invalid number
Any suggestions?
TO_CHAR doesn't fail on null I don't think.
Try:
NVL(TO_CHAR(referred), 'NOT REFERRED')
Try:
NVL(TO_CHAR(referred), 'NOT REFERRED')
Google is your friend. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit http://www.kaelisspace.com/
Bored? Visit http://www.kaelisspace.com/
![]() |
Similar Threads
- Quick Question: Is J# the same thing as Java? (Java)
- Simple array question (C++)
- This has to be a simple question to answer. (Visual Basic 4 / 5 / 6)
- Ribbon Question (Motherboards, CPUs and RAM)
- Simple question (Windows Servers and IIS)
- Simple Question (Linux Servers and Apache)
- A simple question about CMOS batteries (Motherboards, CPUs and RAM)
- XP Pro (re)activation question (Windows NT / 2000 / XP)
Other Threads in the MySQL Forum
- Previous Thread: Help required to setup database
- Next Thread: SELECT COUNT(*) Optimization
| Thread Tools | Search this Thread |
Tag cloud for MySQL
agplv3 alfresco api artisticlicense aws bizspark breathalyzer camparingtocolumns cmg communityjournalism contractors copyright count court data database design developer development distinct drupal dui ec2 eliminate email enter enterprise error eudora facebook form foss government gpl greenit groklaw hiring hyperic innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire law legal license licensing maintenance managing mariadb matchingcolumns metron micromanage microsoft mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery news open-xchange opendatabasealliance opengovernment opensource oracle pdf penelope php query referencedesign remove reorderingcolumns results resultset saas search select sharepoint simpledb sourcecode spotify sql statement sugarcrm syntax techsupport thunderbird transparency update virtualization





