Question

I have to make a table of basketball players and a query which finds the player with the most experience I have tried

SELECT firstName, lastName, MAX(experience) FROM Player

but I'm assuming thats wrong.

So basically I want to find the player with the highest experience (data type set as an INT)

Thank you!! :D

Was it helpful?

Solution

SELECT  firstName, 
        lastName, 
        experience
FROM    Player
WHERE   experience = (SELECT MAX(experience) FROM Player)

OTHER TIPS

SELECT  * FROM Player
WHERE experience = 
(SELECT max(experience) FROM Player)
select top 1 firstName, lastName, experience
from Player
order by experience desc;
select firstName, lastName, experience
from Player
where rownum = 1
order by experience desc;

The correct query is:

Select FirstName, LastName, Experience as Experience_Player
from Player
where experience = (Select MAX(experience) from Player)

Suppose you have following data:

FirstName                     LastName               Experience  
Adam                          Smit                   15  
John                          Carlos                 25  
Ibrahim                       Khan                   10  

When you would apply above mentioned query, you will get the name of Ibrahim Khan because he is the most experienced player.

And if you want to get multiple player having experience more than 10 years, just run this query

Select FirstName, LastName, experience 
from Players
where experience > 10
SELECT FIRSTNAME,LASTNAME,EXPERIENCE FROM (SELECT FIRSTNAME,LASTNAME,EXPERIENCE,DENSE_RANK() OVER (ORDER BY EXPERIENCE DESC) EXP FROM PLAYER) WHERE EXP=1;
select * from (
  select firstname, lastName, experience from player
  order by experience desc)
where rownum = 1
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top