At 11:29 -0500 3/7/03, Peter D Bethke wrote:
>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 such a way to
>double the value of the number 7 for example to the final sum? Ie when the
>SUM() function encounters the number 7, add (score*2) instead of just score
>to the final total.
>SUM(CASE WHEN score = 7 THEN score*2 ELSE score END) AS final_sum
>(Of course this doesn't seem to work, but it's the best I can approximate)
There's no reason it shouldn't work. What was the exact query you used,
and what was the result? What error message, for example.
>Any help, much much appreciated.
>Peter D Bethke