Rick James Wrote:
-------------------------------------------------------
> Is MEDIA() some macro in Excel?
>
> What does "F_SUM" mean? It sounds like it is the
> sum of something. You want the moving average of
> a sum?
>
> I gave you two ways to get moving averages of F1
> and F2. Apply the same principles to F_SUM and
> you will get 62062.50121667.
thank you.
In excel cell I use:
=AVERAGE(F43:F54)
F_SUM is the sum where values in the column F1, F2 and F3
this version of your query working:
mysql> DROP TABLE IF EXISTS `foo`;
CREATE TABLE foo
SELECT ID,
F_SUM, @sum1 := @sum1 + F_SUM AS sum1
FROM `page1-1`
JOIN ( SELECT @sum1 := 0
) init;
SELECT b.ID,
ROUND((b.sum1 - a.sum1) / 12,2) AS MA1
FROM foo a
JOIN foo b ON a.ID = b.ID - 12;
Query OK, 0 rows affected
Query OK, 53 rows affected
Records: 53 Duplicates: 0 Warnings: 0
+----+-----------+
| ID | MA1 |
+----+-----------+
| 13 | 166258.95 |
| 14 | 166897.94 |
| 15 | 167660.15 |
| 16 | 167511.31 |
| 17 | 166994.22 |
| 18 | 167583.42 |
| 19 | 168596.70 |
| 20 | 169391.35 |
| 21 | 167176.32 |
| 22 | 167176.32 |
| 23 | 167176.32 |
| 24 | 167176.32 |
| 25 | 167176.40 |
| 26 | 167176.48 |
| 27 | 167176.40 |
| 28 | 167176.40 |
| 29 | 167176.32 |
| 30 | 167176.32 |
| 31 | 167176.23 |
| 32 | 167176.23 |
| 33 | 167176.15 |
| 34 | 167176.15 |
| 35 | 167159.47 |
| 36 | 167159.39 |
| 37 | 167159.39 |
| 38 | 167159.39 |
| 39 | 167159.31 |
| 40 | 167159.22 |
| 41 | 167159.30 |
| 42 | 167159.30 |
| 43 | 167159.39 |
| 44 | 160841.91 |
| 45 | 152505.38 |
| 46 | 144680.80 |
| 47 | 135687.00 |
| 48 | 125362.51 |
| 49 | 113103.72 |
| 50 | 100506.61 |
| 51 | 87119.27 |
| 52 | 74416.31 |
| 53 | 62062.50 |
+----+-----------+
41 rows in set
Edited 1 time(s). Last edit at 11/05/2013 02:37AM by angel rivero.