declare
  startdate date;
  enddate   date;
begin
  startdate := to_date('2011-09-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss');
  enddate   := to_date('2011-09-15 00:00:00', 'yyyy-mm-dd hh24:mi:ss');
  select t.RECEIVETIME, t.speedometer --83315 412.046s
    from bmps_his_receive_gpsinfo t
   where t.speedometer > 0 --83315 261.187s
     and t.locatestate != 0 --83173 251.438s
     and t.MCUID = 1000000969
     and t.RECEIVETIME between startdate and enddate;
end;一条这么简单的SQL都无法通过,无非就是声明两个变量给SQL语句用!!!!还提示select缺少 into错误,MD 在SQL Server怎么可以这样做!!!!查了很多资料 都不行

解决方案 »

  1.   

    本来就是你自己没写对。你取出值来先申请变量并将它存放在变量里。select A.cc into ls_cc from A;要使用的时候就用ls_cc.
      

  2.   

    Oracle shit啊,明明就是把查出来的全部打印出来,还要拿个东西存储,这不是故意降低效率吗????!!!
      

  3.   

    为什么在SQL Server中直接声明变量,就可以SQL语句中引用,这里绕个弯子 是为了什么个性??
      

  4.   

    想直接查询,这样就行了
    select t.RECEIVETIME, t.speedometer --83315 412.046s
        from bmps_his_receive_gpsinfo t
       where t.speedometer > 0 --83315 261.187s
         and t.locatestate != 0 --83173 251.438s
         and t.MCUID = 1000000969
         and t.RECEIVETIME between to_date('2011-09-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss') and to_date('2011-09-15 00:00:00', 'yyyy-mm-dd hh24:mi:ss');
    在declare里面必须into
      

  5.   

     我本来是这样,但是数据有几千万条,查询的有十多万条,我不确定是否每次where判断的时候要进行类型转换,降低效率。。所以单独做变量!!
      

  6.   

    SQLSERVER->ORACLE是要有一个适应过程的