如题!

解决方案 »

  1.   

    GROUP BY CONVERT(VARCHAR(10),Time,120),Time不会报错,但是依然不是按天排的,按具体小时秒这种来分的组。
      

  2.   

    select day = Convert(varchar(10),time,120), Qty = sum(qty) from tb group by Convert(varchar(10),time,120)
      

  3.   

    GROUP BY CONVERT(VARCHAR(10),Time,120)按这种分组才能达到效果,但是会报分组的常见错误,不在聚合函数与group by子句中的错。
      

  4.   

    关于group by问题,需要按时间的某天来分组sum(),但是在group by后面使用Convert(varchar(10),time,120)会报‘time不在聚合函数与group by子句的错误!老弟,向这样的问题,以后要给个实例才好呀,虽然这样,我还是要回答你的,呵呵。
    declare @t table(A nvarchar(40),createtime datetime)
    insert into @t select 'aaaa',getdate()
    insert into @t select 'aaaa',getdate()
    insert into @t select 'aaaa',getdate()
    insert into @t select 'aaaa',getdate()
    insert into @t select 'aaaa',getdate()
    insert into @t select 'aaaa',getdate()
    insert into @t select 'aaaa',getdate()
    insert into @t select 'aaaa',getdate()
    select *
    from @t
    select count(A) as sum,substring(Convert(varchar(10),createtime,120),1,10)
    from @t
    group by substring(Convert(varchar(10),createtime,120),1,10)
      

  5.   

    不是不想给~是我的sql太长了!七八个表联的,我怕你们不耐烦看啊。