Advertisement

06.30.2008 at 06:26PM PDT, ID: 23528875
[x]
Attachment Details

Access Query with values that may have an expiration date

Asked by printmedia in SQL Query Syntax

Hi all.

I'm trying to work on an access 2003 query that may have items with expiration date. For example:

Item---UnitofMeasure--ConversionFactor--Expiration
123----CASE-----------50---------------------NULL
456---PACK-----------10--------------------06/20/2008
456--PACK------------20--------------------NULL

The query will have sales history, the date field for sales history would be the invoice date, I would like the query to pull the correct conversion factor for an item and unit of measure based on the invoice date and the expiration date (IF THERE IS ONE).

So, let's say I run the query and I have the following data:

Item---UnitOfMeasure--InvoiceDate
123---CASE-----------05/01/2008
456---PACK-----------05/02/2008
456--PACK------------06/30/2008

I would like the results to be:
Item---UnitOfMeasure-----ConversionFactor--InvoiceDate
123----CASE---------------50--------------------05/01/2008
456---PACK---------------10--------------------05/02/2008
456--PACK----------------20--------------------06/30/2008

As you can see, if there ISN'T an expiration date (NULL) then simply apply the conversion factor that's in the table. But if there is an expiration date, then you have to compare it to the expiration date, if there is an expiration date then all the invoice dates that come before the expiration get the corresponding conversion factor, all invoice dates that come after the expiration date (as long as there is one) would get the conversion factor with the null expiration date for that item (as in the example above for item 456).

Thank you in advance!Start Free Trial
[+][-]07.01.2008 at 05:48AM PDT, ID: 21907194

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: SQL Query Syntax
Sign Up Now!
Solution Provided By: MikeToole
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.01.2008 at 08:01AM PDT, ID: 21908490

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.01.2008 at 09:11AM PDT, ID: 21909081

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.01.2008 at 10:31AM PDT, ID: 21909799

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628