OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
RE: Group by column and Sum another

From: Hagen (finhagencomcast.net)
Date: Mon Jul 20 2009 - 11:41:14 CDT


Thanks! That did the trick.

-----Original Message-----
From: Olexandr Melnyk [mailto:omelnykgmail.com]
Sent: Monday, July 20, 2009 10:02 AM
To: mysqllists.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 <finhagencomcast.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=omelnykgmail.com
>
>

--
Sincerely yours,
Olexandr Melnyk
http://omelnyk.net/

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql