Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

invalid number in a select statement

Posted on 2008-09-30
4
Medium Priority
?
820 Views
Last Modified: 2012-05-05
The following query is okay.  
    SELECT code_desc  FROM  dm_codes WHERE   code in   ( SELECT   emp_no FROM emp ) ;

But, the following query result in invalid number.  Why?  Thanks.
            select ( SELECT code_desc   FROM  dm_codes    WHERE  code  = emp_no )  
                             from     ( SELECT   emp_no FROM emp  ) ;


                           
0
Comment
Question by:ewang1205
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
paquicuba earned 1000 total points
ID: 22607274
It looks like you have a column named EMP_NO in dm_codes as well that is a VARCHAR2 datatype, so need to qualify your subselect in order for it to work:

select ( SELECT code_desc   FROM  dm_codes    WHERE  code  = x.emp_no )  
                             from     ( SELECT   emp_no FROM emp  )  x;
 
0
 

Author Comment

by:ewang1205
ID: 22607871
Tried.  That is not where the problem is.  
0
 
LVL 20

Assisted Solution

by:gatorvip
gatorvip earned 1000 total points
ID: 22608993
What is the error that you are getting?
0
 

Author Comment

by:ewang1205
ID: 22609029
The following is working.  I will split the points between you two.  Thanks.
 
select ( SELECT code_desc   FROM  dm_codes    WHERE  code  =  to_char(emp_no  ) )  
                             from     ( SELECT   emp_no FROM emp  ) ;
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question