0

私の質問は、会議ごとに、会議のタイトルと、会議が2012年7月1日より前に開催された場合は「第1期」、2012年7月1日以降に開催された場合は「第2期」という単語を表示することです。「第1項」または「第2項」という単語を含む列には、ヘッダー用語を作成します。それに関連付けられているテーブルは

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

私がどこで間違っているのかを明確にしてください、どんな助けもいただければ幸いです。ありがとうございました

4

1 に答える 1

2

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'

また、の2つの部分unionは相互に排他的であるため、aunion allを使用できます(重複を排除する必要がないため、パフォーマンスが向上します)

于 2013-03-26T16:43:21.053 に答える