Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Mon, 15 May 2006 @ 18:15:53 GMT


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


Subj:   Need assistance with SQL
 
From:   Pinti, Michele

The following SQL works:

     select
     substring(logtime,1,2) || ':00' as runtime,
     logdate,
     count(*) as Qcount
     from dbc.accesslog
     where
     statementtext like '%PRODODS%'
     and logdate >=  date '2006-05-15'
     group by 2,1

Sample output:

     Runtime   LogDate              Qcount
     00:00     2006-05-15           11
     01:00     2006-05-15           3
     02:00     2006-05-15           4
     04:00     2006-05-15           2

We would like to have each hour represented even if a query didn't run (See 03:00)

     Runtime   LogDate              Qcount
     00:00     2006-05-15           11
     01:00     2006-05-15           3
     02:00     2006-05-15           4
     03:00     2006-05-15           0
     04:00     2006-05-15           2

I have been able to do this using our reporting tool and a second query but would like to know how accomplish this efficiently in the SQL listed above.


Thanks in advance,

Michele



     
  <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