Results 1 to 4 of 4
  1. #1
    adnancanada is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2010
    Posts
    121

    how to pickup rate between current dates


    Click image for larger version. 

Name:	exmple.PNG 
Views:	22 
Size:	14.2 KB 
ID:	51383
    Hello everyone,
    I am stuck here you guys can help me out. I have historical rates I need to apply only one rates based on pickup date.
    i want to write sql query that will only pick up RatePerKg between effective and expiry date.

    in this example pickup date 30-jun-2023 which is under this bucket.
    32030 0003001155G20 30-Jun-23 18-Jun-23 30-Dec-23 $10.18

  2. #2
    madpiet is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    154
    You need a non-equijoin to return one record

    SELECT ...
    FROM MyTable mt
    INNER JOIN RatesTable rt ON mt.MyDate >= rt.StartDate AND mt.MyDate <= rt.EndDate

    Wait, that table doesn't make sense. Shouldn't a rates table be something like
    (RateID INT IDENTITY, StartDate DATE NOT NULL, EndDate DATE NOT NULL, Rate DECIMAL(6,2) ) or similar?

    Then you just do a non-equijoin, assuming the rate periods don't overlap.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    that table does not work

    for 30-Jun-23 you have two possible rates: 16-Apr-23 to 30-Dec-23 ($13.72) and 18-Jun-23 to 30-Dec-23 ($10.18)

    On what basis do you decide it should be the second one?

  4. #4
    madpiet is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    154
    Quote Originally Posted by adnancanada View Post
    Click image for larger version. 

Name:	exmple.PNG 
Views:	22 
Size:	14.2 KB 
ID:	51383
    Hello everyone,
    I am stuck here you guys can help me out. I have historical rates I need to apply only one rates based on pickup date.
    i want to write sql query that will only pick up RatePerKg between effective and expiry date.

    in this example pickup date 30-jun-2023 which is under this bucket.
    32030 0003001155G20 30-Jun-23 18-Jun-23 30-Dec-23 $10.18
    This rates table doesn't super make sense. Rate periods shouldn't overlap. Can you post some data? Create table script, insert script, and for the love of all things good and holy, as TEXT and not a picture.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Help With Creating a Form Pickup Tracker Database (?)
    By QueryKid123 in forum Database Design
    Replies: 3
    Last Post: 10-29-2021, 06:08 PM
  2. Using most current employee wage rate
    By cmoogy in forum Access
    Replies: 3
    Last Post: 05-18-2015, 12:50 PM
  3. Filter all dates within current month
    By wanderanwills in forum Access
    Replies: 3
    Last Post: 03-22-2015, 12:03 AM
  4. Showing dates in current month only
    By fistja in forum Queries
    Replies: 2
    Last Post: 04-09-2012, 10:17 AM
  5. Button on Subform to pickup ClientVisitID as Key
    By joefonseca79 in forum Forms
    Replies: 5
    Last Post: 11-23-2010, 04:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums