Calculate a value during the SQL command
| From: | John Hawkins | Date: | Fri, 08 Feb 2002 23:54:11 +0000 |
| Subject: | Calculate a value during the SQL command | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-16740@lists.php.net to get a copy of this message | ||
I know I could very easily do this after doing the
initial database call simply by calculating the two
variables, but, I was wondering if there was a way to
do this during the sql statement so my results would
already have my answer...
Here's the setup. I have two tables. Table A has the
information about a mailing. Table B has an individual
record for each click generated by the e-mail.
They look like this:
TableA
ID // unique identifier
mail_date
mail_qty // shows how many mails were sent
TableB
ID // unique identifier
mail_ID // matches up with the ID in Table A
mem_ID // the member's unique code
Here is what I thought was going to work (but didn't):
SELECT mail_date, mail_qty, count(*) as clicks,
((clicks / mail_qty)*100) as percentage FROM TableA,
TableB WHERE mail_ID = TableA.ID GROUP BY mail_ID
What I was hoping to get back was something like this:
| mail_date | mail_qty | clicks | percentage |
| 2001-02-05 | 1000 | 100 | 10 |
If I need to do this the long way, it's not a huge
deal, but, I thought this may be something I could
do...
I hope I explained that good enough. Thanks for your
help!
__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com