#Allright you can take a read of https
1 messages · Page 1 of 1 (latest)
Hey, in your instructions, can you add order by start_ts desc to the select statement you gave for finding the incorrect values? The order in which the rows are returned is undefined when you do not specify an order by clause. Most of the times it will be in the order the rows were added, but this is not always the case. so if you're looking for irregularities in the growth of the sum value, you really should add that order by clause.
@restive vapor Here is an even better way to find the rows that have a smaller sum than their previous row (limited to 10 results max to limit the number of rows in a possibly very large dataset):
select t.*, t.sum - t.sum_previous as difference from (select s.*, lag(s.sum) over (partition by s.metadata_id order by s.start_ts) as sum_previous from statistics s) t where t.metadata_id = 30 and t.sum < t.sum_previous order by t.start_ts desc limit 10;