Thanks! That did the trick.
-Original Message-
From: Olexandr Melnyk [mailto:omel...@gmail.com]
Sent: Monday, July 20, 2009 10:02 AM
To: mysql@lists.mysql.com
Subject: Re: Group by column and Sum another
select contract , sum(amlp)
from maintenance
group by contract;
On Mon, Jul 20, 2009 at 6:50 PM, Hagen finha...@comcast.net wrote:
I am hoping I can get some help with a query I am trying to construct:
I want to group by a 'contract' column and get the sum of the 'amlp' column
values associated with each contract. I can do a select and group by on
contract
select contract from maintenance group by contract;
and I will get each unique contract. However, I want to sum the amlp values
per unique contract and I am not sure how to construct that select
statement.
I tried:
select contract , sum(amlp) from maintenance where contract=(select
contract
from maintenance group by contract);
But that resulted in a ERROR 1242 (21000): Subquery returns more than 1
row error.
Any suggestions?
Hagen Finley
Boulder
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=omel...@gmail.com
--
Sincerely yours,
Olexandr Melnyk
http://omelnyk.net/
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org