Have you ever wondering how to find MAX, MIN or AVG of a database table column in CakePHP way? Well I haven’t since yesterday. The solution is quite simple and obvious.
Lets say you want to show the average views per post (in the example we have the views field in every post).
The SQL should be something like this:
Instead of using query() function you can use the CakePHP way:
Hope this will help someone.