SELECT u.id, u.username, u.score,
(SELECT COUNT(ownerId) FROM post p WHERE p.ownerId = u.id) AS totalPost
FROM users u
ORDER BY u.score DESC, totalPost DESC LIMIT 10
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
or if you have a User model (I think this will work - I didn't test either of these ;)
Haven't tested it. But it could work like this