SQL query question.
#1

Hey lads,

let's say there are 3 rows in the table:

Код:
Name ------ Money ------ WantedLevel

Test ------  1000  ------ 11
Test2 ------ 40000 ------ 20
Test3 ------ 1337  ------ 50
Now, for example, I want to get the highest Money and WantedLevel values stored in the database.

so I'd do it this way:

Код:
SELECT MAX(Money), MAX(WantedLevel) FROM `table`
and it'd give 40000, 50

But how do I also get the Name, which has the biggest Money and WantedLevel values? That the output would be Test2 - 40000, Test3 - 50

Is it possible to do it in the same query posted above? Or do I also to send several other queries, such like:

Код:
SELECT `Name` FROM `table` WHERE `WantedLevel` = 40000
etc.?

Thanks!
Reply


Messages In This Thread
SQL query question. - by b3nz - 07.07.2015, 19:57
Re: SQL query question. - by Sime30 - 07.07.2015, 20:04
Re: SQL query question. - by b3nz - 07.07.2015, 20:08
Re: SQL query question. - by Sime30 - 07.07.2015, 20:14
Re: SQL query question. - by b3nz - 07.07.2015, 20:22
Re: SQL query question. - by Misiur - 07.07.2015, 20:50
Re: SQL query question. - by b3nz - 07.07.2015, 21:10

Forum Jump:


Users browsing this thread: 1 Guest(s)