|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
From: Hagen (finhagen
comcast.net)
Date: Mon Jul 20 2009 - 11:41:14 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Thanks! That did the trick.
-----Original Message-----
From: Olexandr Melnyk [mailto:omelnyk
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 <finhagen
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=omelnyk
gmail.com
>
>
--
Sincerely yours,
Olexandr Melnyk
http://omelnyk.net/
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]