List:General Discussion« Previous MessageNext Message »
From:kabel Date:May 6 2008 7:46pm
Subject:Percentage growth query.
View as plain text  
I have a table from which I need to calculate the percentage growth of 
downloads from specific countries over two distinct periods of time.  
Calculating the total downloads from a country over one period of time is not 
difficult:

SELECT country, SUM(total_dl) AS q3_total FROM show_history WHERE year = 2007 
AND ( month = 12 OR month = 11 OR month = 10 ) GROUP BY (country);

I need to be able to compare those numbers with the result of:

SELECT country, SUM(total_dl) AS q4_total FROM show_history WHERE year = 2007 
AND ( month = 10 OR month = 11 OR month = 12 ) GROUP BY (country);

I'm currently using temporary tables to store the results of each query, 
however, I think there's a way to accomplish this using subqueries.  

Any thoughts?

TIA,

kabel
Thread
Percentage growth query.kabel6 May 2008