|
Archives of the TeradataForumMessage Posted: Thu, 20 Aug 2015 @ 08:58:18 GMT
Hi, I need help to write a query. Please see details below. I have a table which records hourly value, and data looks like following: Hour value 0 23 1 32 2 44 3 68 5 70 6 65 7 81 I want to calculate average of "value" collected for last consecutive hours (maximum 6 hours). In above data, hour 4 is missing. Query should be able to do the average for values which were collected consecutively and the number of hours for which average was calculated. So query should give me = sum(23+32+44+68)/count(hour) and count(hour) should be 4 (since we are averaging 4 hours) In short, query should return only those records which have consecutive hours and break whenever hours are not continuous. Thanks, Vipin
| ||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||
Copyright 2016 - All Rights Reserved | ||||||||||||||||||||||||||||||||||||||||||||||||
Last Modified: 15 Jun 2023 | ||||||||||||||||||||||||||||||||||||||||||||||||