Writing a Query to distinguish multiple entries

paul29berks

Active Member
Joined
Mar 15, 2004
Messages
293
I am trying to write a query based on the following criteria:

* I am using 2 tables - Table 1 tells me standard discount rates by each product, Table 2 = actual discounts that have been processed.

* I have found for each product in the standard discount table there are several entries in the actual discounts tables.

Does anyone have any suggestions on how I can write a query which makes the following assumptions:

1) If more than 1 entry found take the lowest discount rate?

*2) If I have a standard discount rate of 25% for a limited period i.e a start date of 200101 and an end date of 20010301. How can I write a query that tells me if start date = x and end date = Y discount = Z?

Many Thanks
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
I would use a grouping query.

Build a query on the table that shows actual discounts. Make it a grouping query (click the E looking icon, for summation). Add the field that has the product. Change the group by designation to 'count'. Add a criteria for this field of 2. Add the product field again, this time leave the group by designation set to 'group by'.

Now, add the field that has the discount amount. Set the group by designation for this field to 'min'.

The above should give a listing of all products in this table that are listed at least twice, and the lowest discount used.

Regarding your second question, where do you want this discount displayed, in a query? If so, just add an expression field, and use something like:
disc: IIf([date]>=#1/1/2004# And [date]<=#2/1/2004#,.25)

I notice your dates are in a strange format, that will probably need to be addressed if you have any problems. Use with the cdate() and format() functions if you need to reformat your date.
 
Upvote 0

Forum statistics

Threads
1,221,831
Messages
6,162,250
Members
451,757
Latest member
iours

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top