473,320 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Limiting Records in a Query Using Max

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
ny****@yahoo.com
Nov 12 '05 #1
3 3357
TOP 2

Terry
"Shaiguy" <ny****@yahoo.com> wrote in message
news:81**************************@posting.google.c om...
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
ny****@yahoo.com

Nov 12 '05 #2
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!
Nov 12 '05 #3

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!
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Kingdom | last post by:
I'm using this script to dynamicaly populate 2 dropdowns and dispaly the results. Choose a component type from the first drop down, lets say 'car' and the second box will list all the car...
1
by: BF | last post by:
Hello, I am trying to find out if there is a way to limit the number of rows returned when a cursor is opened. I am using DB2 version 7 on z/OS. The SELECT statement in my DECLARE CURSOR...
4
by: N J | last post by:
Hi, I ahve developed a program using access and am distributing it using MDE's, I ahve had many requests for a demo. I was thinking of limiting the number of records to say 100? If anyone has...
1
by: LFM | last post by:
I have a table called "employee profile" which contains a bunch of user information. In that table I have a field called "Description" which is a text/memo field. This field is not mandetory to...
15
by: Hexman | last post by:
Hello All, How do I limit the number of detail records selected in a Master-Detail set using SQL? I want to select all master records for a date, but only the first 3 records for the details...
1
by: bfountain | last post by:
I have a query which someone wrote in Access and I have been charged with the task of making it work in SQL Server. The query runs fine, but the problem is that I need to get back only 3 records as...
3
by: DDonnachie | last post by:
Hi, I want my query to go through all the employee hours and list the associated rates for each record. This means going through Eng_Costing and linking to Eng_PrjGrds (matching Project and Grade),...
4
WyvsEyeView
by: WyvsEyeView | last post by:
I have a datasheet form in which one field is a combo box that will potentially contain hundreds of records. I've read about several methods of speeding up such combo boxes or limiting their initial...
2
by: Steve | last post by:
I've developed a database that will be used by my team (25 people) The database is based on the Resource Planner template The database will reside on a shared drive. What I'd to do now is create...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.