Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 20 Aug 2015 @ 12:27:24 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: Query to return records which are in sequence
 
From:   Gupta, Vipin

Hi Tom,

Thanks for your suggestion.

However, your query is returning cumulative avg for every row and my 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



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 23 Jun 2019