backfill results for the same month and year

------=_NextPart_000_005C_01CB81B9.904BA300
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

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 =3D 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.

Please help

Thanks
haidarpesebe
------=_NextPart_000_005C_01CB81B9.904BA300--
HaidarPesebe [ Do, 11 November 2010 10:00 ] [ ID #2050279 ]

Re: backfill results for the same month and year

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

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2 [at] m.gmane.org
Mark Goodge [ Do, 11 November 2010 10:06 ] [ ID #2050280 ]

Re: backfill results for the same month and year

------=_NextPart_000_0084_01CB81BF.3606E7F0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I've tried it and succeeded. thanks mark

----- Original Message -----
From: HaidarPesebe
To: MySQL Lists
Sent: Thursday, November 11, 2010 4:00 PM
Subject: backfill results for the same month and year


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 =3D 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.

Please help

Thanks
haidarpesebe
------=_NextPart_000_0084_01CB81BF.3606E7F0--
HaidarPesebe [ Do, 11 November 2010 10:40 ] [ ID #2050281 ]
Datenbanken » gmane.comp.db.mysql.general » backfill results for the same month and year

Vorheriges Thema: buf/buf0buf.c:597 hi count
Nächstes Thema: select data from two tables and SUM qty of the same ID