Connecting Tech Pros Worldwide Forums | Help | Site Map

Limiting Records in a Query Using Max

Shaiguy
Guest
 
Posts: n/a
#1: Nov 12 '05
Does anyone have a clue on how to limit a table (using a Query) to the
most recent 2 records by date ?

Example:

I have a table containing

ProjectAreaID (primaryKey)
ProjectID
Date

For each Project ID, there exists more than 4 records each having a
different date (and thus also having a unique ProjectAreaID). I would
like a Query, which will provide the same fields as above, but only
show the most recent 2 dates for each ProjectID (and the ProjectAreaID
as well).

When I try to use the Max function, and include the PrimaryKey, it
automatically expands the recordset and shows all the records...

HELPPPPPPP !!!!


Please email as well as post.

Best
Shai
nyshai@yahoo.com



Terry Kreft
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Limiting Records in a Query Using Max


TOP 2

Terry


"Shaiguy" <nyshai@yahoo.com> wrote in message
news:81871a1b.0309050607.3f0ab0a0@posting.google.c om...[color=blue]
> Does anyone have a clue on how to limit a table (using a Query) to the
> most recent 2 records by date ?
>
> Example:
>
> I have a table containing
>
> ProjectAreaID (primaryKey)
> ProjectID
> Date
>
> For each Project ID, there exists more than 4 records each having a
> different date (and thus also having a unique ProjectAreaID). I would
> like a Query, which will provide the same fields as above, but only
> show the most recent 2 dates for each ProjectID (and the ProjectAreaID
> as well).
>
> When I try to use the Max function, and include the PrimaryKey, it
> automatically expands the recordset and shows all the records...
>
> HELPPPPPPP !!!!
>
>
> Please email as well as post.
>
> Best
> Shai
> nyshai@yahoo.com[/color]


Shai Moschowits
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Limiting Records in a Query Using Max


I apologize for my ignorance, where would I put "top 2", how do I use
this syntax ? Please elaborate a little.

Best
shai

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Shai Moschowits
Guest
 
Posts: n/a
#4: Nov 12 '05

re: Limiting Records in a Query Using Max



Actually I tried setting the TopValues Property to 2, but it only
returns the top 2 values for the whole table. I need it to return the
top 2 values for every instance in ProjectID.

thoughts ?

S

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Closed Thread


Similar Microsoft Access / VBA bytes