如下:
select card_type,count(*) from tb_AssociatorCard where (open_date between '2008-4-1' and '2008-4-1')and deptid=10 and state=N'已分配' group by card_type
 
为什么查不到数据?请帮忙!

解决方案 »

  1.   

    select card_type,count(*) from tb_AssociatorCard where (open_date >= '2008 -4-1' and open_date<'2008-4-2')and deptid=10 and state=N'已分配' group by card_type
      

  2.   

    -->你原来只查2008-4-1 00:00:00.000的数据:select card_type,count(*) from tb_AssociatorCard where (open_date >= '2008-4-1' and open_date<'2008-4-2')and deptid=10 and state=N'已分配' group by card_type
      

  3.   

    between '2008-4-1' and '2008-4-2'
      

  4.   


    select card_type,count(*) from tb_AssociatorCard where (convert(varchar(10),open_date,120) between '2008-04-30' and '2008-04-01') and deptid=10 and state=N'已分配' group by card_type select card_type,count(*) from tb_AssociatorCard where convert(varchar(10),open_date,120) = '2008-04-01' and deptid=10 and state=N'已分配' group by card_type 
      

  5.   

    再帮忙看下面一段SQL语句有错没?
    select *  from tb_Associator_Message where datediff(dd,getdate(),Birthday)=10
      

  6.   

    可是为什么总是查不到数据?
    我的数据类型是:datetime(1944-1-10 0:00:00)
      

  7.   

    select *  from tb_Associator_Message where datediff(dd,getdate(),Birthday)=10这句有结果的话,birthday为2008-05-15
      

  8.   


    select card_type,count(*) from tb_AssociatorCard where (open_date between '2008-4-1' and '2008-4-1')and deptid=10 and state=N'已分配' group by card_type 
      
    类似于:只查询2008-04-01的数据select card_type,count(*) from tb_AssociatorCard where (open_date='2008-4-1')and deptid=10 and state=N'已分配' group by card_type 
      

  9.   

    各位高手这样就对了吧.
    select *  from tb_Associator_Message where datediff(dd,getdate(),convert(varchar(10),Birthday,120))=10 
      

  10.   


    --谁的生日在今天之后十天?(答:2008-05-15)
    select * from tb_Associator_Message where datediff(dd,Birthday,getdate())=10  
      

  11.   

    呵呵不好意思..见笑了...
    可是有一个'1980-5-9'就是找不到..select *  from tb_Associator_Message where datediff(dd,convert(varchar(10),Birthday,120),getdate())=4
      

  12.   

    select count(*),card_type from tb_AssociatorCard 
    where (cast(open_date as datetime) between '2008-4-1 00:00:00' and '2008-4-1 23:59:59')
    and deptid=10 and state=N'已分配'
    group by card_type