select tableno 
from tableinfo 
where not exists (select * from orderbill inner join ordertable on ordertable.orderno=orderbill.orderno where ordertable.tableno=tableinfo.tableno
and cast(char(10,arrivetime,101)=cast(char(10,selectdate,101) and datename(hh,arrivedate)>=12)

解决方案 »

  1.   

    select c.tableno,c.tablename,c.orderstate 
    from tableinfo as c left join 
    (select b.tableno 
    from orderbill as a inner join ordertable as b on a.orderno=b.orderno
    where (convert(20),arrivetime,121)<(convert(10),arrivetime,126)+' 12:00:00'
    ) as d on c.tableno=d.tableno
      

  2.   

    to   comefirst(自力更生+师夷长技=干掉小日本) cast(char(10,arrivetime,101)=cast(char(10,selectdate,101) 提示 char 函数要求有 1 个参数。to  ibanez550(愤怒的荷包蛋) 提示 '20' 附近有语法错误。请问为何??
      

  3.   

    declare @dt varchar(200)
    set @dt='2005-09-06'
    select c.tableno,c.tablename,c.orderstate 
    from tableinfo as c left join 
    (select b.tableno 
    from orderbill as a inner join ordertable as b on a.orderno=b.orderno
    where arrivetime<dateadd(hh,12,cast(@dt as datetime))
    ) as d on c.tableno=d.tableno
      

  4.   

    sorry,漏写了select c.tableno,c.tablename,c.orderstate 
    from tableinfo as c left join 
    (select b.tableno 
    from orderbill as a inner join ordertable as b on a.orderno=b.orderno
    where convert(varchar(20),arrivetime,121)<convert(varchar(10),arrivetime,126)+' 12:00:00'
    ) as d on c.tableno=d.tableno