jeudi 25 décembre 2014

Sorting Table and get Position of row


I have a Table with 3 rows. Player, Time, Server. Now, I want 2 things and I don't know how. For Server the're 3 worths available. 1, 2 and 3. Server and Player are a Primary Key together. User is a VARCHAR, Server and Time are Strings. I use 1,2 and 3 to make i easier to understand.


1st I want to sort the table by time and get the position of a specific player, but only from 1 Server. Example:


User Time Server 2 10 1 1 50 1 2 60 3 1 20 2 1 100 3 2 70 2


Now, want to get which position the user 2 has if I sort by time and server = 1. In this case, user 2 would be number 2 and user 1 number 1. If server = 2, user 2 would be 1 and user 1 would be 2.


Then I want to get the User position, if I sort by the sum of the time of a user. In this case, user 1 would be 1 (Sum of time: 170) and user 2 would be 2 (Sum of time:100).


I hope you can help me! BTW, I want to use this in Java ;)


~java4ever/Robin





Aucun commentaire:

Enregistrer un commentaire