I'm trying to form an sql statement to compute the kill/death ratio of players that I am keeping stats for.
the database table has the following columns:
UserData Table: userName, defeatedName, location, killDate
sample data for the table:
http://i5.photobucket.com/albu...love113/sampledata.jpg
basically, 'userName' is the person who killed 'defeatedName'.
I have a sql query that computes the top 20 users with most kills as:
SELECT userName, count(userName),
FROM UserData
WHERE killDate > DATE_SUB(now(),
INTERVAL 1 HOUR)
Group By userName
order by count(userName)
DESC limit 20;
but I can't figure out how to compute the top 20 users with the best kill ratio.
I'm thinking I should right a stored procedure to do this but I think there should be
an sql query that can do this?