0

I have a table KIDS that have a Column AGE. I want to use an SQL query to get all the records of the oldest kids.

For example: If I have

Name   Age
----------
David   10 
Dan     10
Leah     8 
Hannah   6

I want to get David's and Dan's records.

a_horse_with_no_name
  • 497,550
  • 91
  • 775
  • 843
Dina Kleper
  • 1,675
  • 3
  • 15
  • 21
  • 2
    Possible duplicate of [SQL select only rows with max value on a column](https://stackoverflow.com/questions/7745609/sql-select-only-rows-with-max-value-on-a-column) – Nick Feb 05 '19 at 06:37

3 Answers3

1

You can try below -

select * from tablename
where age in (select max(age) from tablename)
Fahmi
  • 36,607
  • 5
  • 19
  • 28
0

use max()

  select * from t where age = (select max(age) from t)
Zaynul Abadin Tuhin
  • 30,345
  • 5
  • 25
  • 56
0

You can apply the below code:

select * from old_Records where age =(select max(age) from old_Records)
Sahil Anand
  • 139
  • 5