Hi David, Try
Select company, state, sales, sum(sales) / sales as percent >From Sales GROUP BY company, state; Not sure if you always want to group by state; if each company exists in only one state then the group by is irrelevant, if not then it will give you the by-state breakdown. On Fri, 2008-07-25 at 10:53 -0400, David Ruggles wrote: > I get: > Error Code : 1140 > Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is > illegal if there is no GROUP BY clause > > Thanks, > > David Ruggles > CCNA MCSE (NT) CNA A+ > Network Engineer Safe Data, Inc. > (910) 285-7200 [EMAIL PROTECTED] > > > > -----Original Message----- > From: Ananda Kumar [mailto:[EMAIL PROTECTED] > Sent: Friday, July 25, 2008 10:37 AM > To: David Ruggles > Cc: mysql > Subject: Re: How do I (can I) use aggregate functions inside a select > > > yes, u can use the below sql. > > regards > anandkl > > > On 7/25/08, David Ruggles <[EMAIL PROTECTED]> wrote: > > > > I may be approaching this all wrong, but I need to know a percentage of > > total sales within a select statement. > > > > So I can do something like this: > > Select company, state, sales, sum(sales) / sales as percent > > From Sales > > > > > > Thanks, > > > > David Ruggles > > CCNA MCSE (NT) CNA A+ > > Network Engineer Safe Data, Inc. > > (910) 285-7200 [EMAIL PROTECTED] > > > > > > > > -- > > MySQL General Mailing List > > For list archives: http://lists.mysql.com/mysql > > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] > > > > > No virus found in this incoming message. > Checked by AVG - http://www.avg.com > Version: 8.0.138 / Virus Database: 270.5.6/1572 - Release Date: 7/25/2008 > 6:51 AM > > > -- Ian Simpson System Administrator MyJobGroup -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]