简体   繁体   English

ORA-01858:找到一个非数字字符,其中数字是预期的 - oracle 10g

[英]ORA-01858: a non-numeric character was found where a numeric was expected - oracle 10g

My question is: For each conference, display conference title and words "First term" if the conference took place before July1, 2012 or the words "Second term" if the conference took place on or after July1,2012. 我的问题是:对于每个会议,如果会议在2012年7月1日之前举行,则显示会议标题和“第一学期”字样,如果会议在2012年7月1日或之后举行,则显示“第二学期”字样。 For the column holding the words "First term" or "Second term" make a header Term. 对于包含“第一学期”或“第二学期”字样的专栏,请填写标题术语。 The table associated with it is 与之关联的表是

CONFID             TITLE                    LOCATION          SDATE
------        --------------------       -------------------- ---------
c00001    Hydroinformatics                  Singapore          15-JUN-12
c00002    Ecological_modeling                Berlin            15-JUL-12
c00003    Computational_M                    London            25-MAY-12
c00004    Ecoinformatics                     Boston            22-AUG-12
c00005    Uncertainty_analysis               Athens            10-OCT-12
c00006    Large_databases                    Toronto           13-APR-12
c00007    Systems_analysis                    Boston           23-MAR-12
c00008    Systems_integration                 Tokyo            24-FEB-12
c00009    Aquatic_biology                      Helsinki        12-MAY-12
c00010    Information_systems                   Paris          08-JAN-12
c00011    Simulation_modeling                   Rome           01-SEP-12
c00012    DSS                                  Melbourne       18-DEC-12

The sql statement that I wrote is: 我写的sql语句是:

select C.Title, 'First term' as "Term" 
from Conference_C C 
where C.ConfID in (select C.Sdate 
                   from Conference_C C 
                   where C.Sdate < '1-July-12') 
union 
select C.Title, 'Second term' as "Term" 
from Conference_C C 
where C.ConfID in (select C.Sdate 
                     from Conference_C C 
                     where C.Sdate >= '1-July-12');

I get the following error: 我收到以下错误:

select C.Title, 'First term' as "Term" from Conference_C C where C.ConfID
                                                                 *
ERROR at line 1:
ORA-01858: a non-numeric character was found where a numeric was expected

Please clarify where I am going wrong, any help would be appreciated. 请澄清我哪里出错了,任何帮助将不胜感激。 Thank You 谢谢

You are comparing the ConfID (a number) to a Sdate (a date) that is returned from your inner query: 您正在将ConfID (数字)与从内部查询返回的Sdate (日期)进行比较:

where C.ConfID in (select C.Sdate 
                   from Conference_C C 
                   where C.Sdate < '1-July-12') 

All you need is a simple SQL like this: 您只需要一个像这样的简单SQL:

select C.Title, 'First term' as "Term" 
from Conference_C C 
where C.Sdate < '1-July-12'
union
select C.Title, 'Second term' as "Term" 
from Conference_C C 
where C.Sdate >= '1-July-12'

Also since the two parts of the union are mutually exclusive, a union all can be used (which performs better because it does not have to eliminate duplicates) 还由于两个部分union是互斥的,一个union all可以使用(其执行更好,因为它不必消除重复)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ORA-01858:在期望数字的地方找到了非数字字符? - ORA-01858: a non-numeric character was found where a numeric was expected? ORA-01858: 在需要数字的地方发现了一个非数字字符(时间戳、解码) - ORA-01858: a non-numeric character was found where a numeric was expected (timestamp, decode) 可能的日期分配错误ORA-01858:在期望数字的位置找到了非数字字符 - Possible Date assignment error ORA-01858: a non-numeric character was found where a numeric was expected ORA-01858: 在需要数字的地方发现了一个非数字字符 - ORA-01858: a non-numeric character was found where a numeric was expected ORA-01858:找到一个非数字字符,其中数字是预期的? 即使数值是数字? - ORA-01858: a non-numeric character was found where a numeric was expected? Even when the values are numbers? ORA-01858: 在一个简单的选择查询需要数字的地方发现了一个非数字字符 - ORA-01858: a non-numeric character was found where a numeric was expected for a simple select query .NET ORA-01858:找到了一个非数字字符,其中包含数字 - .NET ORA-01858: a non-numeric character was found where a numeric was expected 错误 ORA-01858:在运行查询时应为数字的位置发现了非数字字符 - Error ORA-01858: a non-numeric character was found where a numeric was expected when running query 看到 ORA-01858:在需要数字的地方发现了一个非数字字符 - Seeing ORA-01858: a non-numeric character was found where a numeric was expected ORA-01858:找到非数字字符并期望输入数字 - ORA-01858: a non-numeric character found where a digit was expected
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM