List:General Discussion« Previous MessageNext Message »
From:Mark Goodge Date:November 11 2010 9:06am
Subject:Re: backfill results for the same month and year
View as plain text  
On 11/11/2010 09:00, HaidarPesebe wrote:
> Dear All,
>
> I have the following data
>
> ID CITY      QTY   MONTH YEAR
> -------------------------------
> 1  Chigago    10     11       2010
> 1  NewYork   22     11       2010
> 1  London     54     11       2010
> 1  Chigago    7      10       2010
> 1  NewYork   26     10       2010
> 1  London     33     10       2010
>
> ID = ID PRODUCT.
>
> How can I backfill results with the same ID by month and year, with results like
> this:
>
> MONTH/YEAR    QTY TOTAL
> ---------------------------
> 11/2010            86
> 10/2010            66
> and etc.

select ID, concat(MONTH,'/',YEAR) as MONTHYEAR, sum(QTY) as TOTAL
from MYTABLE
group by concat(ID,MONTH,YEAR)

Mark
-- 
http://mark.goodge.co.uk
Thread
backfill results for the same month and yearHaidarPesebe11 Nov
  • Re: backfill results for the same month and yearMark Goodge11 Nov
Re: backfill results for the same month and yearHaidarPesebe11 Nov