group by two columns and adding new key per type in array
Here's my table:
date | capacity
10/09/13 | 100
10/09/13 | 50
10/09/13 | 100
08/09/13 | 100
Low capacity is 50 and high capacity is 100.
I'm trying to retrieve an average capacity per day per capacity type. So
the expected result is:
10/09/13-
low capacity average: 50
high capacity average: 100
08/09/13-
low capacity average: 0
high capacity average: 100
My query at the moment is: SELECT date, capacity FROM table GROUP BY date,
capacity
What should I add in order to present the customized capacity types (low,
high) in array?
something like:
$array =
[['date'=>'10/09/13','high_capacity'=>100,'low_capacity'=>50],['date'=>'08/09/13','high_capacity'=>100,'low_capacity'=>0]];
Thanks!
No comments:
Post a Comment