select * from telecast 
where 
cast (playdate+' '+laybegin as datetime) between '2003-04-1 05:00:00'
and '2003-04-2 05:00:00'

解决方案 »

  1.   

    select * from telecast 
    where ( playdate >= '2003-04-1 05:00:00' and playdate <= '2003-04-2 03:00:00')
      

  2.   

    试试这个:
    select * from telecast
    where year(playdate)*365*24+month(playdate)*30*24+day(playdate)*24 >= 2003*365*24+4*30*24+1*24+5
    and year(playbegin)*365*24+month(playbegin)*30*24+day(playbegin)*24 <= 2003*365*24+4*30*24+2*24+3
    查询2003-4-1年05:00:00至2003-4-2年03:00:00之间的数据,要playbegin干嘛?
      

  3.   

    呆滯 1-3
    select * from TABLE a where sho2<=3
     where exists (select ISNULL(count(*),0) from TABLE where a.sho1=sho1 and a.sho2=sho2 
     AND sh09<>0  group by  sho1  having count(*)=0)
    呆滯 4-6
    select * from TABLE a where sho2>=4 AND sho2<=6
     where exists (select ISNULL(count(*),0) from TABLE where a.sho1=sho1 and a.sho2=sho2  AND ISNULL(sh09,0)<>0  group by  sho1  having count(*)=0
    呆滯 7-10
    select * from TABLE a where sho2>=7 AND sho2<=10
     where exists (select ISNULL(count(*),0) from TABLE where a.sho1=sho1 and a.sho2=sho2  AND ISNULL(sh09,0)<>0  group by  sho1  having count(*)=0
    呆滯 12
    select * from TABLE a where sho2=12
     where exists (select ISNULL(count(*),0) from TABLE where a.sho1=sho1 and a.sho2=sho2  AND ISNULL(sh09,0)<>0  group by  sho1  having count(*)=0
    )
    呆滯 24
    select * from TABLE a where sho2=24
     where exists (select ISNULL(count(*),0) from TABLE where a.sho1=sho1 and a.sho2=sho2  AND ISNULL(sh09,0)<>0  group by  sho1  having count(*)=0
    )
      

  4.   

    vic_darkstar(松子):
    没办法,我也知道playbegin是个累赘,但是数据表是人家的,我只是负责读出来。该不料的
      

  5.   

    select convert(varchar(50),playbegin,108) as playbegin,convert(varchar(50),playdate,102) as playdate from telecast where convert(varchar(50),playdate,102) + convert(varchar(50),playbegin,108) >= '2003-04-01'+'05:00:00'为什么这样查询也不行?
      

  6.   

    select * from telecast 
    where playdate >= '2003-04-1 05:00:00'  
    and playdate <= '2003-04-2 03:00:00'
      

  7.   

    select * from telecast 
    where ( playdate + playbegin ) between '2003-04-1 05:00:00'  
    and '2003-04-2 03:00:00'
      

  8.   

    select * from telecast 
    where cast(convert(varchar(10),playdate,120)+ ' ' + convert(varchar(10),playbegin,108) as datetime) between '2003-04-1 05:00:00' and '2003-04-2 03:00:00'
      

  9.   

    playbegin < '1899-12-30 03:00:00' ???