在用QRChart制作数据曲线统计图时,
 query1.SQL.Add('select count(code),date11 from table1');
从服务器上取出date11的时间是“年-月-日-小时-分-秒”格式,但这样在QRCHart表中根本看清资料,因为它是按每秒统计 的。现在只需要按每小时来统计数据,形成曲线图。应该怎么做?

解决方案 »

  1.   


    select DISTINCT(LEFT(CONVERT(VarChar,date11,120),13)) AS dd,Count(*) As ccc from Table1
    group by LEFT(CONVERT(VarChar,date11,120),13)
      

  2.   

    SQL中使用getdate()代替date11通過:select count(code),cast(left(convert(varchar(50),date11,20),Len(convert(varchar(50),date11,20))-6)+':00' as datetime) as date11 from table1
      

  3.   

    这样看行不,to_date(to_char(datell,'yyyymmdd hh'),'yyyymmdd hh'))
    不记得怎么写了,大概的意思是先将时间转换为只含时间的字符,然后再转换为时间