top id by date

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hey does anyone know how to get the say top 1 by id with the hightest date,
for example:
date name id
22/11/5 anna 1
1/1/4 john 2
5/5/4 sasha 3
4/8/5 anna 1
6/9/5 John 2
4/8/5 john 2

the result should display:
22/11/5 anna 1
5/5/4 sasha 3
6/9/5 John 2

displaying all the id by the top date. does any one know how to do this?
 
SELECT Max([Date]), [Name], [ID]
FROM [YouTable]
GROUP BY [Name], [ID]

If you Field names are actually "Date" and "Name", suggest you change them
to something elsr as both are reserved words in Access / VBA.
 
Hey thanks,

but i got another problem, it has price, when i add another column with
price in it, it shows everything. I should have mention this before? is there
a way to get around it!



Van T. Dinh said:
SELECT Max([Date]), [Name], [ID]
FROM [YouTable]
GROUP BY [Name], [ID]

If you Field names are actually "Date" and "Name", suggest you change them
to something elsr as both are reserved words in Access / VBA.

--
HTH
Van T. Dinh
MVP (Access)



mel said:
Hey does anyone know how to get the say top 1 by id with the hightest
date,
for example:
date name id
22/11/5 anna 1
1/1/4 john 2
5/5/4 sasha 3
4/8/5 anna 1
6/9/5 John 2
4/8/5 john 2

the result should display:
22/11/5 anna 1
5/5/4 sasha 3
6/9/5 John 2

displaying all the id by the top date. does any one know how to do this?
 
Yes, you definitely need to mention that you want to det the values of
related Fields and include this in the sample data.

See The Access Web article:

http://www.mvps.org/access/queries/qry0020.htm

for different techniques.

--
HTH
Van T. Dinh
MVP (Access)



mel said:
Hey thanks,

but i got another problem, it has price, when i add another column with
price in it, it shows everything. I should have mention this before? is
there
a way to get around it!



Van T. Dinh said:
SELECT Max([Date]), [Name], [ID]
FROM [YouTable]
GROUP BY [Name], [ID]

If you Field names are actually "Date" and "Name", suggest you change
them
to something elsr as both are reserved words in Access / VBA.

--
HTH
Van T. Dinh
MVP (Access)



mel said:
Hey does anyone know how to get the say top 1 by id with the hightest
date,
for example:
date name id
22/11/5 anna 1
1/1/4 john 2
5/5/4 sasha 3
4/8/5 anna 1
6/9/5 John 2
4/8/5 john 2

the result should display:
22/11/5 anna 1
5/5/4 sasha 3
6/9/5 John 2

displaying all the id by the top date. does any one know how to do
this?
 
Back
Top