473,397 Members | 1,969 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,397 software developers and data experts.

How to Select the Highest Number or Date

I have two table in MS Access, Bids and Remarks the are linked by a BidID One-to-Many. Bids have no duplicated. Remarks has many duplicates.

I want to select a BidID in Bids tables and only the highest (newest) remark to that Bid by the newest RemDate or RemID.

Bids Table Remarks Table
BidID -------------> BidID
Bid Name RemID
Customer Name RemDate
Bid Manager Remarks

Thanks
Mike
Jun 13 '16 #1
3 906
PhilOfWalton
1,430 Expert 1GB
Air Code
Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT BidsTable.BidID, BidsTable.BidName, BidsTable.CustomerName
  3. Bidstable.BidManager, RemarksTable.RemID, RemarksTable.Remark, 
  4. RemarksTable.RemDate
  5. FROM BidsTable INNER JOIN RemarksTable 
  6. ON BidsTable.BidID = RemarksTable.BidID
  7. WHERE RemarksTable.RemarkDate = DMax("RemarkDate", "RemarksTable", 
  8. "BidID = " & BidTable!BidID);
  9.  
Incidentally, you need the comparison with the Remarks Date, noy the REMID, because, although unlikely the date for a particular REMID could be changed. There is no guarantee that they are both in ascending order.

You will need to do an ORDER BY to get things in the correct order

Phil
Jun 13 '16 #2
jforbes
1,107 Expert 1GB
Something like this should work:
Expand|Select|Wrap|Line Numbers
  1. SELECT
  2.   BidID
  3. , [Customer Name]
  4. , [Bid Manager]
  5. , (SELECT TOP 1 Remarks 
  6.    FROM Remarks 
  7.    WHERE Bids.BidID=Remarks.BidID
  8.    ORDER BY RemDate DESC) AS LatestRemark
  9. FROM Bids
Jun 13 '16 #3
Hi Phil

Thanks, I'll try it and get back to you.

Mike
Jun 13 '16 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: trint | last post by:
Ok, I just need to know how to get the last record inserted by the highest IDENTITY number. Even if the computer was rebooted and it was two weeks ago. (Does not have to do with the session)....
1
by: Rick | last post by:
I have field with many numbers and I wish to make by code another number which is bigger than the highest number already in field by one. I do not wish to use the autonumber. Can anyone help.
21
by: Jaspreet | last post by:
I was working on some database application and had this small task of getting the second highes marks in a class. I was able to do that using subqueries. Just thinking what is a good way of...
3
by: Grant | last post by:
Hello, How would I get the highest number from a column? The table has an ID column but it does not auto imcrement and I have to do it manually so I need to get the hihest integer value and...
2
by: movieking81 | last post by:
If someone could help me with this, that would be great. I need to select a number of records from an SQL table based on a date range, so I started with this select. <html> <code> resultssql =...
1
by: faizan qazi | last post by:
Hello Greetings Guide Me To Find Second Highest Number In Array
10
by: strife | last post by:
Hi, This is a homework question. I will try to keep it minimal so not to have anyone do it for me. I am really just stuck on one small spot. I have to figure out the highest number from a users...
5
by: dotray2k7 | last post by:
Hi guys first post woooo!....can believe some of you guys are doing this for a living with things as complex as software...while I cant get past outputting the highest number a user enters...LOL ...
3
by: MyMarlboro | last post by:
i wonder am i make a mistake or not... use Data::Dumper; my @array= qw(1 2 3 4 5 6 8 9 2 5); my $highest=@array; foreach my $number (@array) { if (@array > $highest) { $highest = @array;
25
by: LBinGA | last post by:
Hello all: I'm having trouble with a nested If Statement working properly. I'm working in MS Access 2002 (OS Windows XP, ver 2002). The non-working code is going on the Form (a Single) as follows:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.