查询适用于Oracle 11g,但在Oracle 8i上失败

时间:2014-02-14 07:29:25

标签: oracle oracle11g oracle8i

我在Oracle 11g中运行此查询没有问题:

select (case
         when seqnum = 1 then
          '1'
         when seqnum = cnt then
          '0'
       end) as value1,
       (case
         when seqnum = 1 then
          t.BEGIN_DT
         when seqnum = cnt then
          t.END_DT
       end) as TIME1,      
       t4.UNIT1 || '.SUBBATCH_TRIGGER' TAG     
  from (select t.*,
               row_number() over(partition by t.BATCH_ID, t.plant_unit, t3.ID2 order by t.BEGIN_DT) as seqnum,
               count(*) over(partition by t.BATCH_ID, t.plant_unit, t3.ID2) as cnt
          from SCH2.tb_pg_unit_stap t
join (select ID1,batch_id from SCH2.VW_BATCH) t2 on t.BATCH_ID = t2.BATCH_ID
join (select ID2,ID1 from SCH1.STEP) t3 on t3.ID1 = t2.ID1) t
join SCH2.TB_W_MACHINE t4 on t4.plant_unit = t.plant_unit
where (seqnum = 1
    or seqnum = cnt) AND (t.BEGIN_DT > '01-jan-2013' AND t.BEGIN_DT < '01-feb-2013');

但是当我在Oracle 8i(8.7.1)中运行它时,它给出了ORA-00933:SQL命令没有正确结束。

在Oracle 8i中运行sql命令时,我是否需要特别注意?

提前致谢

2 个答案:

答案 0 :(得分:1)

自9i以来引入了AFAK案例命令。

答案 1 :(得分:0)

好的-跳闸-停下车道时间:

select decode(seqnum,
                1,    '1',
                cnt,  '0') as value1,
       decode(seqnum,
                1,    t.BEGIN_DT,
                cnt,  t.END_DT) as TIME1,      
       t4.UNIT1 || '.SUBBATCH_TRIGGER' TAG     
  from (select t.*,
               row_number() over (partition by t.BATCH_ID, t.plant_unit, t3.ID2
                                  order by t.BEGIN_DT) as seqnum,
               count(*) over (partition by t.BATCH_ID, t.plant_unit, t3.ID2) as cnt
          from SCH2.tb_pg_unit_stap t
          INNER join (select ID1, batch_id
                        from SCH2.VW_BATCH) t2
            on t.BATCH_ID = t2.BATCH_ID
          INNER join (select ID2, ID1
                        from SCH1.STEP) t3
            on t3.ID1 = t2.ID1) t
  INNER join SCH2.TB_W_MACHINE t4
    on t4.plant_unit = t.plant_unit
  where (seqnum = 1 or seqnum = cnt) AND
        (t.BEGIN_DT > '01-jan-2013' AND t.BEGIN_DT < '01-feb-2013');