Jump to content

Mysql MAX()


wongerlt

Recommended Posts

Hi all.

I have query

SELECT name,game,score, MAX(score) FROM `servers` WHERE `on`='2' group BY `game` DESC

but it bad ;/

I need:

Example:

id - name - game - score

1 - test - 45 - 78

2. - iks - 13 - 43

3. - lips - 45 - 15

4. - cat - 45 - 74

5. - dog - 13 - 56

...

and i need query a mains so:

1.test 78

2.dog 56

 

one rezult from one game with max score.

 

Soz for bad english.

Link to comment
Share on other sites

Thx.

But what here wrong:

SELECT ids, game, score
FROM   shop s1
WHERE  score=(SELECT MAX(s2.score)
              FROM shop s2
              WHERE s1.ids = s2.ids) GROUP BY `game`;

table:

ids.      game    score

4568 12 2056

4646 12 3

454564 13 75

8778 13 16

46487 13 1

4541 24 56

13131 24 87

6464 24 185

 

i get result:

ids.    game.  score.

4541 24 56

454564 13 75

4568 12 2056

 

but should be:

ids.      game.  score.

4568 12 2056

454564 13 75

6464 24 185

 

why last result is bad?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.