Consumption Bars Graphs

zabbix

#1

Hello Gentlemen,
I would like to thank all members and designer here in this community I have a query and I need to get a Graphic bar chart to draw the daily consumptions for CO2 Gas

here Scripts as below

declare @_ consumptionTable table (RecordID int identity, TagName varchar(50), Time DateTime, Value decimal(22,2), consumptionValue decimal(22,2))

insert into @_ consumptionTable (TagName, Time, Value)
SELECT TagName, DateTimen as Time, Value
FROM History
WHERE TagName IN (‘MWDashBoardIOs.C1_Co2’)
AND wwRetrievalMode = ‘Cyclic’
AND wwResolution = 86400000
AND wwQualityRule = ‘Extended’
AND wwVersion = ‘Latest’
AND $__timeFilter(DateTime) ORDER by 1

declare @_ count int = (select count(1) from @_ consumptionTable)
declare @_ index int = 0
declare @_ previousID int = 0
declare @_ currentID int = 0
declare @_ previousValue decimal (22,2)
declare @_ currentValue decimal (22,2)

while (@_ index < @_ count)
begin
if (@_ index = 0)
Begin
set @_ currentID = (select top 1 recordID from @_ consumptionTable)
set @_ index = @_ index + 1
continue;
End

set @_ previousID = @_ currentID
set @_ currentID = (select recordID from @_ consumptionTable where recordID = @_ index-1)

set @_ currentValue = (select isnull(value, 0) from @_ consumptionTable where RecordID = @_ currentID)
set @_ previousValue = (select isnull(value, 0) from @_ consumptionTable where RecordID = @_ previousID)

update @_ consumptionTable set consumptionValue = @_ currentValue - @_ previousValue where RecordID = @_ previousID

set @_ index = @_ index + 1

end

select * from @_ consumptionTable

"


#2

Note : i replaced @ by "@_ "