Home > other >  How do I select row with maximum value of some column
How do I select row with maximum value of some column

Time:01-05

Hi this seems like very easy task but I could not find answer for it. I would like to get only one row from table where some specific column has maximum value.

So, for example if I have this table:

╔═══════╦═════╦═══════╗
║ Name  ║ Age ║ Color ║
╠═══════╬═════╬═══════╣
║ Jakub ║  55 ║ Red   ║
║ Nick  ║  24 ║ Black ║
║ Alice ║  38 ║ Blue  ║
╚═══════╩═════╩═══════╝

I would like to know how can I get the row "Jakub 55 Red" based on that the age is maximal.

I though it will be something like select * from people where age is max but it doesn't work. I am using TimesTen.

CodePudding user response:

SELECT S.NAME,S.AGE,S.COLOR
FROM YOUR_TABLE AS S
WHERE S.AGE=(SELECT MAX(AGE) FROM YOUR_TABLE) 

Could you please try this one

CodePudding user response:

Based on Stu's answer the solution I was looking for is select first 1 * from people order by age desc, thank you all for help!

  •  Tags:  
  • Related