Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 20 Nov 2002 @ 19:35:35 GMT


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


Subj:   Re: Can anyone explain this query
 
From:   David Wellman

This looks like it has come from one of the NCR courses.

Overall, the query is returning the average daily sales value. For instance, if the daily sales vaues for three days were 80, 90 and 100, this query would return a value of 90 as the single row answer.

The derived table portion...

SELECT
SUM(Sales_Amount) FROM Sales_Hist GROUP BY
Period_Date) Temp(Daily_Amt);

calulates the total sales by date (date column is Period_Date).

The outer query portion...

SELECT AVG(Daily_Amt) AS Daily_Average FROM

then calculates the average of these daily sales totals.

Dave

Ward Analytics Ltd: Information in motion (www.ward-analytics.com)



     
  <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