declare @i int , @selectStr Varchar(5005), @j Varchar(2) set @i=0 set @j='0' set @selectStr='select ' while @i<=24 begin if @i<24 set @selectStr=@selectStr+' datepart(hh,''00:00'')+'+@j+' As T'+@j+' ,' else set @selectStr=@selectStr+' datepart(hh,''00:00'')+'+@j+' AS T'+@j Set @i=@i+1 set @j=Cast(@i As varchar(2)) end exec(@selectStr) 结帖吧
慢着,再改进一下:declare @i int , @selectStr Varchar(5005), @j Varchar(2) set @i=0 set @j='0' set @selectStr='select ' while @i<=24 begin if @i<24 set @selectStr=@selectStr+'(Cast( datepart(hh,''00:00'')+'+@j+' As Varchar(6))+'':00'') As T'+@j+' ,' else set @selectStr=@selectStr+'(Cast( datepart(hh,''00:00'')+'+@j+' as Varchar(6))+'':00'') AS T'+@j Set @i=@i+1 set @j=Cast(@i As varchar(2)) end exec(@selectStr)
在向指定日期加上一段时间的基础上,返回新的 datetime 值。语法
DATEADD ( datepart , number, date )
from table
where .....series.xvalues.valuesourc:='时间'
series.yvalues.valuesourc:='value1'
x轴必须是字符型
我上面的代码已经可以给楼主足够的提示了chart组件的实现如下 可以参考
chart.series[0].add(1,inttostr(1));
这条语句显示点(1,1)
@selectStr Varchar(5005),
@j Varchar(2)
set @i=0
set @j='0'
set @selectStr='select '
while @i<=24
begin
if @i<24
set @selectStr=@selectStr+' datepart(hh,''00:00'')+'+@j+' As T'+@j+' ,'
else
set @selectStr=@selectStr+' datepart(hh,''00:00'')+'+@j+' AS T'+@j Set @i=@i+1
set @j=Cast(@i As varchar(2))
end
exec(@selectStr)
结帖吧
@selectStr Varchar(5005),
@j Varchar(2)
set @i=0
set @j='0'
set @selectStr='select '
while @i<=24
begin
if @i<24
set @selectStr=@selectStr+'(Cast( datepart(hh,''00:00'')+'+@j+' As Varchar(6))+'':00'') As T'+@j+' ,'
else
set @selectStr=@selectStr+'(Cast( datepart(hh,''00:00'')+'+@j+' as Varchar(6))+'':00'') AS T'+@j Set @i=@i+1
set @j=Cast(@i As varchar(2))
end
exec(@selectStr)