List:General Discussion« Previous MessageNext Message »
From:Tompkins Neil Date:August 31 2010 12:07pm
Subject:Re: MySQL SUM on two columns
View as plain text  
Hi,

I also wondered, if there is any way to LIMIT the products.rating for each
language to say the top 25 ?

Cheers
Neil

On Tue, Aug 31, 2010 at 12:11 PM, Tompkins Neil <
neil.tompkins@stripped> wrote:

> Perfect.  Exactly what I was looking for.
>
> Cheers John.
>
> Regards,
> Neil
>
> On Tue, Aug 31, 2010 at 12:06 PM, John Daisley <daisleyjohn@stripped
> > wrote:
>
>> SELECT products_sales.language, SUM(products.rating) AS products_rating
>>
>> FROM products_sales
>> INNER JOIN products ON products_sales.products_id = products.products_id
>> WHERE products.enabled = 1
>> AND products_sales.language IN ('EN','ES')
>> GROUP BY products_sales.language
>>
>>
>> Will give the sum for each language.
>>
>> On 31 August 2010 11:42, Tompkins Neil
> <neil.tompkins@stripped>wrote:
>>
>>> Hi,
>>>
>>> I've the following basic SUM for our products based on a rating.
>>>
>>> SELECT SUM(products.rating) AS products_rating
>>> FROM products_sales
>>> INNER JOIN products ON products_sales.products_id = products.products_id
>>> WHERE products.enabled = 1
>>> AND products_sales.language = 'EN'
>>>
>>> This works fine, however I also want to SUM the ES language within the
>>> same
>>> query.  Is this possible to do, or should I just query the table twice,
>>> replacing the language parameter ?
>>>
>>> Thanks.
>>>
>>> Neil
>>>
>>
>>
>>
>> --
>> John Daisley
>>
>> Certified MySQL 5 Database Administrator
>> Certified MySQL 5 Developer
>> Cognos BI Developer
>>
>> Telephone: +44 (0)7918 621621
>> Email: john.daisley@stripped
>>
>
>

Thread
MySQL SUM on two columnsTompkins Neil31 Aug
  • RE: MySQL SUM on two columnsmisiaQ31 Aug
    • Re: MySQL SUM on two columnsTompkins Neil31 Aug
  • Re: MySQL SUM on two columnsJohn Daisley31 Aug
    • Re: MySQL SUM on two columnsTompkins Neil31 Aug
      • Re: MySQL SUM on two columnsTompkins Neil31 Aug