Re: RE:[PHP-DB] How do I do math with a UNION ALL

From: Date: Sun, 17 Apr 2011 03:23:31 +0000
Subject: Re: RE:[PHP-DB] How do I do math with a UNION ALL
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-47764@lists.php.net to get a copy of this message
Thank you for the suggestion. This is the actual query that I implemented: Amazing how this works. Ron SELECT SUM( impressions_total ) AS impressions_total , SUM( usage_total ) AS usage_total FROM ( ( SELECT IF ( SUM( web_advertisements_our_clients_usage.impressions ) , SUM( web_advertisements_our_clients_usage.impressions ) , 0 ) AS impressions_total, IF ( SUM( web_advertisements_our_clients_usage.usage ) , SUM( web_advertisements_our_clients_usage.usage ) , 0 ) AS usage_total FROM web_advertisements_our_clients_usage WHERE web_advertisements_our_clients_reference = $web_advertisements_our_clients_reference AND month = $stats_month AND year = $stats_year LIMIT 1 ) UNION ALL ( SELECT impressions AS impressions_total, usage as usage_total FROM web_advertisements_our_clients WHERE reference = $web_advertisements_our_clients_reference LIMIT 1 ) ) AS monthly_stats_total; The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info

« previous php.db (#47764) next »