|
Archives of the TeradataForumMessage Posted: Thu, 20 Aug 2015 @ 12:28:15 GMT
Hello Sandeep, The query you provided is not returning correct avg. For following data: col_hour col_value 1 10 2 20 3 30 4 40 6 50 7 60 8 70 9 80 10 90 11 100 12 110 Your query is returning avg as 20 however it should be 25. Let me try to explain scenario again. Requirement is to return the "avg of all values" and "number of hours" used for which col_hour data is in sequence. Consider following data for reference: col_hour col_value 1 10 2 20 3 30 4 40 6 50 7 60 8 70 9 80 10 90 11 100 12 110 Since col_hour is breaking after 4th hour, Output of the query should be: Avg NoOfHrsUsed --- ----------- 25 4 Another sample: col_hour col_value 1 10 2 20 3 30 4 40 5 50 7 60 8 70 9 80 10 90 11 100 12 110 Since col_hour is breaking after 5th hour, Output of the query should be: Avg NoOfHrsUsed --- ----------- 30 5 Thanks, Vipin
| ||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||
Copyright 2016 - All Rights Reserved | ||||||||||||||||||||||||||||||||||||||||||||||||
Last Modified: 15 Jun 2023 | ||||||||||||||||||||||||||||||||||||||||||||||||