我想获得设计总视图/图片数量的流行度:这是代码:
$users = DB::query("SELECT * ,
COUNT(p.id) as numPics,
SUM(p.views) as totalViews
COUNT(p.views)/SUM(p.id) as popularity
FROM
images p
INNER JOIN
users u
ON
p.user_id = u.id
WHERE
p.created_at >= \"$current_month\"
GROUP BY p.user_id
ORDER BY popularity DESC LIMIT 10");
我收到此错误:语法错误或访问冲突:1064 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以了解在 'COUNT(p.views)/SUM(p.id) 附近使用的正确语法作为流行度