表结构
ID    U_name   in_time          out_time   Day_time
GUID    aaa   2008-8-5 11:10:12    null     2008-8-5 8:10:11我想查询特定U_name 在当天也就是day_time中是否已经查如过 in_time
我写的查询语句
select count(*)
from inout
where convert(char(10),getdate(),023)=(select convert(char(10),max(day_time),023) 
from inout) and (U_name='aaa') and (in_time <> null)可为什么返回结果都是0不论是in_time是否为null

解决方案 »

  1.   

    select count(*) 
    from inout 
    where convert(char(10),getdate(),023)=(select convert(char(10),max(day_time),023) 
    from inout) and (U_name='aaa') and (in_time is not null) 
      

  2.   

    select count(*)
    from zhang
    where convert(char(10),getdate(),023)=(select convert(char(10),max(day_time),023) from zhang) 
    and (U_name='aaa') 
    结果为1
    问题就在(in_time <> null) 
      

  3.   

    select count(*)
    from zhang
    where convert(char(10),getdate(),023)=(select convert(char(10),max(day_time),023) from zhang) 
    and (U_name='aaa') 
    结果为1
    问题就在(in_time <> null)