I've got that rank query with left join. Trying to limit results to 3 rows, but getting all results instead.
SELECT
CONCAT(users.name, users.surname) n,
total_time v,
1+(SELECT count(*) from app a WHERE a.total_time > b.total_time) r
FROM app b
LEFT JOIN users
ON b.user_id = users.user_id
ORDER by total_time DESC
LIMIT 3
I know I could wrap it into another select and then limit it (this is how it was and it used to work) but the change is needed since this is part of more complex query.
Query does react on DESC
to ASC
change, but on LIMIT val
doesn't.
If I change b.user_id
to app.user_id
- It throws #1054 - Unknown column 'app.user_id' in 'on clause'
How do I limit this to get 3 rows at the most? Where is the scope of the LIMIT
I used?