Hello listers,
In mysql, is it possible imbed a conditional CASE statement within a SUM()
function to effect how the SUM() returns the final value for a set of rows?
For example, if I have a table foo with column score, and score has
the rows with the values 1 to 10, can I write the SUM() in
Peter,
I think something like this will work:
mysql select sum( if(score=7, score * 2, score)) from table_name;
David
-
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
At 11:29 -0500 3/7/03, Peter D Bethke wrote:
Hello listers,
In mysql, is it possible imbed a conditional CASE statement within a SUM()
function to effect how the SUM() returns the final value for a set of rows?
For example, if I have a table foo with column score, and score has
the rows with the
That's also right:
select sum( case 1 when score=7 then score * 2 else score end) from foo;
[EMAIL PROTECTED] on 03/07/2003
11:28:03 AM
To: Peter D Bethke [EMAIL PROTECTED], MySQL List
[EMAIL PROTECTED]
cc:(bcc: David P. Giragosian/MDACC)
Subject: Re: CASE statement