--StartTime是datetime类型吗?
try:
select Sender,count(*) as count from MReport.A 
join MReport.B on MReport.A.ID=MReport.B.ID 
where convert(varchar(10),StartTime,120) between '2003-07-09' and '2003-07-10' group by Sender having count(*)>1 

解决方案 »

  1.   

    try:
    select Sender,count(*) as count from MReport.A 
    join MReport.B on MReport.A.ID=MReport.B.ID 
    where convert(varchar(10),StartTime,120) >= '2003-07-09' and convert(varchar(10),StartTime,120)<='2003-07-10' group by Sender having count(*)>1
      

  2.   

    程序里如果要加引号,应该这样啊
    'select Sender,count(*) as count from MReport.A join MReport.B on MReport.A.ID=MReport.B.ID where StartTime between ''2003-07-09'' and ''2003-07-10'' group by Sender having count(*)>1' 
      

  3.   

    应该可以的,试:
    select Sender,count(*) as count from MReport.A join MReport.B on MReport.A.ID=MReport.B.ID where StartTime >= '2003-07-09' and StartTime <= '2003-07-10' group by Sender having count(*)>1
      

  4.   

    谢谢各位,
    我的程序是这样的.sprintf(sql1,"select Sender,count(*) from MReport.moaMessage,MReport.goaEngineDetail where MReport.moaMessage.ID=MReport.goaEngineDetail.ID where StartTime between '2003-07-09' and '2003-07-10' group by Sender having count(*)>%s",count);....rs->Open (sql1,_variant_t((IDispatch*)cn,true),adOpenStatic,adLockOptimistic,adCmdText);但现在还是不行.
      

  5.   

    between ... and 是包括了两个时间点,想当于<=  >=如果要选之间的信息,改成<   and  >
      

  6.   

    现在的问题是
    where StartTime<='2003-07-09'
    是正确的,
    但如果加上andwhere StartTime<='2003-0709' and StartTime>='2003-07-08'
    就出现错误了.
      

  7.   

    where StartTime<='2003-07-09' and StartTime>='2003-07-08'
    应该没有错啊,可能是语句的其他地方