Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 20 Aug 2015 @ 12:28:15 GMT


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


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

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



     
  <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: 15 Jun 2023