* Steve Katen
> alright, not sure if i can even do this or not, but i figured the list
> would know.
>
> here is the query i have:
> SELECT count(ID),sum(pnt1)+sum(pnt2)+sum(pnt3)+sum(pnt4) FROM
> wiseQuiz_questions WHERE test='$test'
>
> here is the table structure i have:
> CREATE TABLE `wiseQuiz_questions` (
>    `ID` int(11) NOT NULL auto_increment,
>    `test` int(11) default NULL,
>    `question` text,
>    `ans1` text,
>    `ans2` text,
>    `ans3` text,
>    `ans4` text,
>    `pnt1` int(11) default NULL,
>    `pnt2` int(11) default NULL,
>    `pnt3` int(11) default NULL,
>    `pnt4` int(11) default NULL,
>    PRIMARY KEY  (`ID`)
> );
>
> the values that i am concerned with are the pnt1, pnt2, pnt3 and pnt4
> fields.  as you can see with the query i am simply summing each of the
> columns.  what i would like to do is out of the four fields only add the
> HIGHEST value to the sum.  is there a way to do that?  some of
> the values i
> have are below:
>
> 3     2       1       0
> 2     3       0       1
>
> in this scenario i would want to see the total as 6, rather than 12.  see
> where i am going?

Maybe you can use the function called GREATEST()...?

<URL: http://www.mysql.com/doc/M/a/Mathematical_functions.html >

Something like:

SELECT count(ID),sum(greatest(pnt1,pnt2,pnt3,pnt4)) FROM
  wiseQuiz_questions WHERE test='$test'

--
Roger


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to