Page 1 of 1

Sum of Columns for a Record

Posted: Tue Mar 30, 2004 4:17 am
by Pyrite
How can I get the SUM of all columns in a row ? No I don't mean get the SUM of one column for a bunch of rows either, the SQL SUM() Function is not what I need ( I don't think ). :roll:

Posted: Tue Mar 30, 2004 4:17 am
by twigletmac
Which db are you using?

Mac

Posted: Tue Mar 30, 2004 4:18 am
by Pyrite
MySQL, but I'd prefer an ANSI SQL method if possible.

Posted: Wed Mar 31, 2004 6:57 pm
by Weirdan
hmm...

Code: Select all

select field1+field2+field3+field4+.... as sum_of_all_columns from your_table where condition_here
=)

Posted: Wed Mar 31, 2004 7:18 pm
by Pyrite
seems like i tried that ... hold on a sec..

Posted: Wed Mar 31, 2004 9:01 pm
by Pyrite
Ok, now that works. Swear it didn't before, but Weirdan must have blew his magic dust on my db. Thanks man!! ;)