have the below query:
select
hr,
red
from
(select
hour(event_datetime) hr,
max(red_kills) - (select
max(red_kills)
from
vwmatchall
where
date_format(event_datetime,"%Y-%m-%d %H") = date_format(date_sub(event_datetime, interval 1 hour), "%Y-%m-%d")) as red
from
vwmatchall
where
date(event_datetime) = '2015-10-09'
group by
hour(event_datetime)) k
the data is structured as such:
the idea is to take the current max() value of a given column, red_kills in the above example, and subtract it from the max() value of the same column, but one hour previous. it's basically to show the difference by hour. so even if one date doesn't have data for all 24 hours, it would still show data for the hours it does have. any idea what's wrong with the query?