Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT t.id, t.name, t.votes
- FROM (
- SELECT r.id, r.name, COUNT(v.id_user) AS votes
- FROM restaurants r,
- user_votes v
- WHERE v.id_restaurant = r.id
- AND v.DATE = ?1
- GROUP BY r.id, r.name
- ) t
- WHERE t.votes =
- (SELECT MAX(votes)
- FROM (SELECT COUNT(v2.id_user) AS votes
- FROM user_votes v2
- WHERE v2.DATE = ?1
- GROUP BY v2.id_restaurant))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement