MySQL query, total amount

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

MySQL query, total amount

Post by JKM »

Hi,
how do get the total amount from a field? Example (paid):
`id`, `paid`, `timestamp`
1, 200, 21321321
2, 250, 34543534
3, 50, 12332453
Result should then be (200+250+50=500).
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: MySQL query, total amount

Post by Darhazer »

SELECT SUM(paid) as total FROM tablename;
Post Reply