I have a table like this:
ID | Type | Value | Timestamp
--------------------------------
1 | AAA | 0.5 | day 1 hour 1
2 | BBB | 1.5 | day 1 hour 1
3 | CCC | 1.8 | day 1 hour 1
.....
11 | AAA | 0.6 | day 1 hour 2
12 | BBB | 1.4 | day 1 hour 2
13 | CCC | 1.5 | day 1 hour 2
.....
ID := Int, PK, AI, and so on
Type := String/Varchar
Value := Double
Timestamp := Unix Timestamp (Int), could be easily changed to date type
What I want is now an average for specific timeframes. For example:
I want all AAA and all BBB with an average of "Value" for day 1 till day 3. Every day has 24 entries per type over several days.
Expected result would be
Type | Average | Timestamp/Date
-------------------------------
AAA | 0.5242 | Day 1
AAA | 0.5442 | Day 2
AAA | 0.5913 | Day 3
BBB | 1.4228 | Day 1
BBB | 1.6924 | Day 2
BBB | 1.3018 | Day 3
I'm not sure if this is possible just with mysql. Maybe it's more efficient to do it with PHP?