I am trying to convert the following SQL query into Kirby’s way of Db querying:
SELECT video,
SUM(rate) AS rates_sum,
COUNT(*) AS votes
ROUND(AVG(rate), 1) AS movie_average
FROM votes
GROUP BY video
$db = Db::table('votes');
$videos = $db->select('video, `SUM(rate)` AS rates_sum, `COUNT(*)` AS votes, `ROUND(AVG(rate), 1)` AS movie_average')
->group('video')
->all();
dump('videos: ' . $videos);
The SQL query returns the expected results, but the php code returns nothing. What am I doing wrong?