select 消费项目,sum(数量) as 数量,sum(金额) as 合计金额 from 收银表
where CAST ( 时间+' '+日期 as datetime) >'2004-01-02 12:00:00' and 
CAST ( 时间+' '+日期 as datetime) <'2004-01-03 12:00:00' group by 消费项目

解决方案 »

  1.   

    where abs(convert(float,convert(datetime ,日期+' '+时间)-'2004-01-03')<0.50000
      

  2.   

    少一边括号:where abs(convert(float,convert(datetime ,日期+' '+时间)-'2004-01-03'))<0.50000
      

  3.   

    select 消费项目,sum(数量) as 数量,sum(金额) as 合计金额 
    from 收银表
    where 日期+' '+时间>='2004-01-02 12:00:00'
    and 日期+' '+时间<'2004-01-03 12:00:00'
      

  4.   

    --或:
    select 消费项目,sum(数量) as 数量,sum(金额) as 合计金额 
    from 收银表
    where 日期>='2004-01-02' and 时间>='12:00:00'
    and 日期<='2004-01-02' and 时间<'12:00:00'