Convert SQL query to Ruby help
Posted
by Verloren
on Stack Overflow
See other posts from Stack Overflow
or by Verloren
Published on 2010-06-16T21:04:40Z
Indexed on
2010/06/16
23:02 UTC
Read the original article
Hit count: 388
Hey all,
I need to query my database table to find which employee has the most support tickets related to them. I can do this just fine using this MySQL query:
SELECT employee_id, COUNT(id) AS number_of_tickets FROM tickets GROUP BY employee_id ORDER BY number_of_tickets DESC LIMIT 1;
How would write this in Ruby-on-Rails?
Thanks very much for your assistance.
I use Ruby version 1.8.6, Rails version 2.2.2 and MySQL Server version 5.0.
© Stack Overflow or respective owner