Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
Pyrite
Forum Regular
Posts: 769 Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:
Post
by Pyrite » Tue Mar 30, 2004 4:17 am
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 ).
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Tue Mar 30, 2004 4:17 am
Which db are you using?
Mac
Pyrite
Forum Regular
Posts: 769 Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:
Post
by Pyrite » Tue Mar 30, 2004 4:18 am
MySQL, but I'd prefer an ANSI SQL method if possible.
Weirdan
Moderator
Posts: 5978 Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine
Post
by Weirdan » Wed Mar 31, 2004 6:57 pm
hmm...
Code: Select all
select field1+field2+field3+field4+.... as sum_of_all_columns from your_table where condition_here
=)
Pyrite
Forum Regular
Posts: 769 Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:
Post
by Pyrite » Wed Mar 31, 2004 7:18 pm
seems like i tried that ... hold on a sec..
Pyrite
Forum Regular
Posts: 769 Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:
Post
by Pyrite » Wed Mar 31, 2004 9:01 pm
Ok, now that works. Swear it didn't before, but Weirdan must have blew his magic dust on my db. Thanks man!!