Re: Calculate a value during the SQL command
| From: | John Hawkins | Date: | Sat, 09 Feb 2002 00:27:23 +0000 |
| Subject: | Re: Calculate a value during the SQL command | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-16742@lists.php.net to get a copy of this message | ||
Now why didn't I try that???
Thanks for your help. Worked like a charm!
John
--- DL Neil <PHPml@DandE.HomeChoice.co.uk> wrote:
> John,
>
> > 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!
>
>
> If the "clicks" is removed from the formula, and
> replaced with "count(*)" does that solve the
> problem?
>
> Let us know!
> =dn
>
>
__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com