本帖最后由 zhqqhao 于 2013-08-19 10:50:29 编辑

解决方案 »

  1.   

    x.substrb(room_no,1,2) 这里应该写的不对吧,应该是substrb(x.room_no,1,2),其他的也类似
      

  2.   

    x.substrb(room_no,1,2)这样的写法肯定有问题
    表别名都放在字段前面,而不能放在函数前边
      

  3.   

    select substrb(room_no,1,2) , nvl(t.b,0)
      from tbl_xstj x ,
          (select substrb(room_no),1,2) a ,count(p_key) b
             from tbl_xstj
               where endtime is null and begintime is not null
                 group by a) t
      where x.substrb(room_no,1,2) = t.substrb(room_no,1,2)
      group by x.substrb(room_no,1,2);
    这样试试呢,