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.

Dina Kleper
  • 1,949
  • 4
  • 17
  • 23
  • 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
  • 37,315
  • 5
  • 22
  • 31
0

use max()

  select * from t where age = (select max(age) from t)
Zaynul Abadin Tuhin
  • 31,407
  • 5
  • 33
  • 63
0

You can apply the below code:

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