Re: Query help - add results then divide by

2004-02-25 Thread vpendleton
What about 
SELECT (SUM( ads.col * 1.91)  * ads.depth ) ) / 131.77
FROM ads
WHERE date = '2004-02-26'
AND editionID = '13'
AND ads.page = '16'


 Original Message 

On 2/25/04, 4:19:12 PM, Rogers, Dennis [EMAIL PROTECTED] wrote 
regarding Query help - add results then divide by :


   Good afternoon,

   How can I take the 3 results below add them together then divide
 by
 131.77?

   Can it all be done in one SQL statement?

   Thanks in advance.

   mysql describe ads;
   
 +---+---+--+-+++
   | Field | Type  | Null | Key | Default| Extra
 |
   
 +---+---+--+-+++
   | adID  | int(11)   |  | PRI | NULL   |
 auto_increment |
   | page  | int(11)   |  | | 0  |
 |
   | adnum | varchar(20)   |  | ||
 |
   | date  | date  |  | | -00-00 |
 |
   | depth | decimal(3,2)  | YES  | | 0.00   |
 |
   | timestamp | timestamp(14) | YES  | | NULL   |
 |
   | col   | int(11)   | YES  | | 0  |
 |
   | acc   | varchar(50)   |  | ||
 |
   | editionID | int(11)   |  | | 0  |
 |
   
 +---+---+--+-+++
   9 rows in set (0.00 sec)

   mysql SELECT ((ads.col * 1.91)  * ads.depth)  FROM ads Where
 date =
 '2004-02-26' AND editionID = '13' AND ads.page = '16';
   +-+
   | ((ads.col * 1.91)  * ads.depth) |
   +-+
   |7.64 |
   |   34.38 |
   |7.64 |
   +-+
   3 rows in set (0.01 sec)

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: Query help - add results then divide by

2004-02-25 Thread Rogers, Dennis
Thanks so much!!

SELECT (SUM(( ads.col * 1.91)  * ads.depth ) / 131.77) * 100
FROM ads
WHERE date = '2004-02-26'
AND editionID = '13'
AND ads.page = '16'

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 25, 2004 5:55 PM
To: Rogers, Dennis
Cc: '[EMAIL PROTECTED]'; '[EMAIL PROTECTED]'; Hines, David
Subject: Re: Query help - add results then divide by 


What about 
SELECT (SUM( ads.col * 1.91)  * ads.depth ) ) / 131.77
FROM ads
WHERE date = '2004-02-26'
AND editionID = '13'
AND ads.page = '16'


 Original Message 

On 2/25/04, 4:19:12 PM, Rogers, Dennis [EMAIL PROTECTED] wrote 
regarding Query help - add results then divide by :


   Good afternoon,

   How can I take the 3 results below add them together then divide
 by
 131.77?

   Can it all be done in one SQL statement?

   Thanks in advance.

   mysql describe ads;
   
 +---+---+--+-+++
   | Field | Type  | Null | Key | Default| Extra
 |
   
 +---+---+--+-+++
   | adID  | int(11)   |  | PRI | NULL   |
 auto_increment |
   | page  | int(11)   |  | | 0  |
 |
   | adnum | varchar(20)   |  | ||
 |
   | date  | date  |  | | -00-00 |
 |
   | depth | decimal(3,2)  | YES  | | 0.00   |
 |
   | timestamp | timestamp(14) | YES  | | NULL   |
 |
   | col   | int(11)   | YES  | | 0  |
 |
   | acc   | varchar(50)   |  | ||
 |
   | editionID | int(11)   |  | | 0  |
 |
   
 +---+---+--+-+++
   9 rows in set (0.00 sec)

   mysql SELECT ((ads.col * 1.91)  * ads.depth)  FROM ads Where
 date =
 '2004-02-26' AND editionID = '13' AND ads.page = '16';
   +-+
   | ((ads.col * 1.91)  * ads.depth) |
   +-+
   |7.64 |
   |   34.38 |
   |7.64 |
   +-+
   3 rows in set (0.01 sec)


Re: Query help - add results then divide by

2004-02-25 Thread Bob Ramsey
I think that you can just do this:

select sum(ads.col)*1.191*sum(ads.depth)/131.77 where date ='2004-02-26' 
AND editionID = '13' AND ads.page = '16';

because of the disttributive property of multiplication.

(2 * 1.191) +(6*1.91) +(4*1.91)/131.77 = 12 *1.91/131.77 = 
(12*1.91)/131.77 = 12*(1.91/131.77)

Test it to make sure I understand what you're asking, but it worked for 
my in my tests.

bob
Rogers, Dennis wrote:
	Good afternoon,

How can I take the 3 results below add them together then divide by
131.77?
	Can it all be done in one SQL statement?

	Thanks in advance.

mysql describe ads;

+---+---+--+-+++
| Field | Type  | Null | Key | Default| Extra
|

+---+---+--+-+++
| adID  | int(11)   |  | PRI | NULL   |
auto_increment |
| page  | int(11)   |  | | 0  |
|
| adnum | varchar(20)   |  | ||
|
| date  | date  |  | | -00-00 |
|
| depth | decimal(3,2)  | YES  | | 0.00   |
|
| timestamp | timestamp(14) | YES  | | NULL   |
|
| col   | int(11)   | YES  | | 0  |
|
| acc   | varchar(50)   |  | ||
|
| editionID | int(11)   |  | | 0  |
|

+---+---+--+-+++
9 rows in set (0.00 sec)
mysql SELECT ((ads.col * 1.91)  * ads.depth)  FROM ads Where date =
'2004-02-26' AND editionID = '13' AND ads.page = '16';
+-+
| ((ads.col * 1.91)  * ads.depth) |
+-+
|7.64 |
|   34.38 |
|7.64 |
+-+
3 rows in set (0.01 sec)
 

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: Query help - add results then divide by

2004-02-25 Thread Sasha Pachev
Rogers, Dennis wrote:
	Good afternoon,

How can I take the 3 results below add them together then divide by
131.77?
	Can it all be done in one SQL statement?

	Thanks in advance.

mysql describe ads;

+---+---+--+-+++
| Field | Type  | Null | Key | Default| Extra
|

+---+---+--+-+++
| adID  | int(11)   |  | PRI | NULL   |
auto_increment |
| page  | int(11)   |  | | 0  |
|
| adnum | varchar(20)   |  | ||
|
| date  | date  |  | | -00-00 |
|
| depth | decimal(3,2)  | YES  | | 0.00   |
|
| timestamp | timestamp(14) | YES  | | NULL   |
|
| col   | int(11)   | YES  | | 0  |
|
| acc   | varchar(50)   |  | ||
|
| editionID | int(11)   |  | | 0  |
|

+---+---+--+-+++
9 rows in set (0.00 sec)
mysql SELECT ((ads.col * 1.91)  * ads.depth)  FROM ads Where date =
'2004-02-26' AND editionID = '13' AND ads.page = '16';
+-+
| ((ads.col * 1.91)  * ads.depth) |
+-+
|7.64 |
|   34.38 |
|7.64 |
+-+
3 rows in set (0.01 sec)



SELECT SUM((ads.col * 1.91)  * ads.depth)/131.77  FROM ads Where date =
 '2004-02-26' AND editionID = '13' AND ads.page = '16';


--
Sasha Pachev
Create online surveys at http://www.surveyz.com/
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]