![](/img/trans.png)
[英]ORA-01858: a non-numeric character was found where a numeric was expected?
[英]ORA-01858: a non-numeric character was found where a numeric was expected - oracle 10g
我的問題是:對於每個會議,如果會議在2012年7月1日之前舉行,則顯示會議標題和“第一學期”字樣,如果會議在2012年7月1日或之后舉行,則顯示“第二學期”字樣。 對於包含“第一學期”或“第二學期”字樣的專欄,請填寫標題術語。 與之關聯的表是
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
我寫的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');
我收到以下錯誤:
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
請澄清我哪里出錯了,任何幫助將不勝感激。 謝謝
您正在將ConfID
(數字)與從內部查詢返回的Sdate
(日期)進行比較:
where C.ConfID in (select C.Sdate
from Conference_C C
where C.Sdate < '1-July-12')
您只需要一個像這樣的簡單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'
還由於兩個部分union
是互斥的,一個union all
可以使用(其執行更好,因為它不必消除重復)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.