query

  • Thread starter igg via AccessMonster.com
  • Start date
I

igg via AccessMonster.com

Display last game for a given player:
Table1:
ID Player Game date time Gender City
1 PL1 G1 d1 t1 M C1
2 PL1 G2 d1 t2 M C2

Output:
ID Player Game date time Gender City
2 PL1 G2 d1 t2 M C2
 
J

John W. Vinson

Display last game for a given player:
Table1:
ID Player Game date time Gender City
1 PL1 G1 d1 t1 M C1
2 PL1 G2 d1 t2 M C2

Output:
ID Player Game date time Gender City
2 PL1 G2 d1 t2 M C2

What constitutes the "last" game? Access tables HAVE NO ORDER; they should be
seen as an unordered heap of data. Do you actually have dates and times in the
(badly named, these are reserved words) fields named 'date' and 'time'?
 
I

igg via AccessMonster.com

Ok. How about?
(t2 > t1)
ID Player Game gdate gtime Gender City
ID1 PL1 G1 d1 t1 M C1
ID2 PL1 G2 d1 t2 M C2

Output:
ID Player Game gdate gtime Gender City
ID2 PL1 G2 d1 t2 M C2
Display last game for a given player:
Table1:
[quoted text clipped - 5 lines]
ID Player Game date time Gender City
2 PL1 G2 d1 t2 M C2

What constitutes the "last" game? Access tables HAVE NO ORDER; they should be
seen as an unordered heap of data. Do you actually have dates and times in the
(badly named, these are reserved words) fields named 'date' and 'time'?
 
J

John W. Vinson

How about some actual data, datatypes of fields, specific example? What if you
have different gdate values in the two fields? Are these really dates and
times respectively, or are they something else? It is impossible to tell from
what you've posted.

AT A GUESS, groping in the dark here...

You'ld be much better off having a single date/time field with the date and
time. You can easily extract either portion with DateValue() and TimeValue().

You can use a Subquery

=(SELECT Max(X.datetimefield) FROM yourtable AS X)

on the date time field. It's possible if you store the time of the game in two
fields, but much more difficult.
Ok. How about?
(t2 > t1)
ID Player Game gdate gtime Gender City
ID1 PL1 G1 d1 t1 M C1
ID2 PL1 G2 d1 t2 M C2

Output:
ID Player Game gdate gtime Gender City
ID2 PL1 G2 d1 t2 M C2
Display last game for a given player:
Table1:
[quoted text clipped - 5 lines]
ID Player Game date time Gender City
2 PL1 G2 d1 t2 M C2

What constitutes the "last" game? Access tables HAVE NO ORDER; they should be
seen as an unordered heap of data. Do you actually have dates and times in the
(badly named, these are reserved words) fields named 'date' and 'time'?
 
I

igg via AccessMonster.com

how about?.
ID Player gdate gtime Gender City
ID1 PL1 5/4/2007 10:00AM M C1
ID2 PL1 5/4/2007 05:00PM M C2
ID3 PL2 5/7/2007 02:00PM M C1
ID4 PL2 5/9/2007 09:00AM M C2
ID5 PL2 5/9/2007 11:00AM M C3


Output:
ID Player gdate gtime Gender City
ID2 PL1 5/4/2007 05:00PM M C2
ID5 PL2 5/9/2007 11:00AM M C3


How about some actual data, datatypes of fields, specific example? What if you
have different gdate values in the two fields? Are these really dates and
times respectively, or are they something else? It is impossible to tell from
what you've posted.

AT A GUESS, groping in the dark here...

You'ld be much better off having a single date/time field with the date and
time. You can easily extract either portion with DateValue() and TimeValue().

You can use a Subquery

=(SELECT Max(X.datetimefield) FROM yourtable AS X)

on the date time field. It's possible if you store the time of the game in two
fields, but much more difficult.
Ok. How about?
(t2 > t1)
[quoted text clipped - 15 lines]
 
D

Douglas J. Steele

As John says, you should combine the Date and TIme into a single field.

To get the results for which you're looking, see what Allen Browne has at
http://www.allenbrowne.com/subquery-01.html#TopN

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


igg via AccessMonster.com said:
how about?.
ID Player gdate gtime Gender City
ID1 PL1 5/4/2007 10:00AM M C1
ID2 PL1 5/4/2007 05:00PM M C2
ID3 PL2 5/7/2007 02:00PM M C1
ID4 PL2 5/9/2007 09:00AM M C2
ID5 PL2 5/9/2007 11:00AM M C3


Output:
ID Player gdate gtime Gender City
ID2 PL1 5/4/2007 05:00PM M C2
ID5 PL2 5/9/2007 11:00AM M C3


How about some actual data, datatypes of fields, specific example? What if
you
have different gdate values in the two fields? Are these really dates and
times respectively, or are they something else? It is impossible to tell
from
what you've posted.

AT A GUESS, groping in the dark here...

You'ld be much better off having a single date/time field with the date
and
time. You can easily extract either portion with DateValue() and
TimeValue().

You can use a Subquery

=(SELECT Max(X.datetimefield) FROM yourtable AS X)

on the date time field. It's possible if you store the time of the game in
two
fields, but much more difficult.
Ok. How about?
(t2 > t1)
[quoted text clipped - 15 lines]
seen as an unordered heap of data. Do you actually have dates and times
in the
(badly named, these are reserved words) fields named 'date' and 'time'?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top