How do you do Min function

WLC

Registered User.
Local time
Today, 03:39
Joined
Jun 19, 2012
Messages
63
I have searched high and low and I can't for the life of me figure out how to find the Minimum value of a column.

This is my SQL:

SELECT *
FROM tblFinalMaster
WHERE (((tblFinalMaster.OperatingDay)=[forms]![frmEnterParameters]![Combo13]) AND ((tblFinalMaster.[Checkout Order])=([Forms]![frm01ATFTieLineCheckout]![Checkout Order])+2) AND ((tblFinalMaster.[From BA_REPORT])=[forms]![frmEnterParameters]![Combo5]) AND ((tblFinalMaster.[TO BA_REPORT])=[Forms]![frmEnterParameters]![Combo3]));

The part in blue, instead of pulling a +2, I want the Minimum value. Seems simple enough.
 
Your form control can only return one value, so there is no min

It might be an idea if you show some data that relates to [Forms]![frm01ATFTieLineCheckout]![Checkout Order] and the result required so we can understand what it is you are trying to do
 
Well I'm certain I'm going about it the wrong way. All I want to do is get to the one minimum value in the Checkout Order field (which in this case would be a 1, there are other cases where it would be something like a 17). If are multiple low values, pick the first one. See attachment to see what the four fields in question look like.
 

Attachments

  • Access Table2.jpg
    Access Table2.jpg
    43.7 KB · Views: 74
Tip:
Instead to try to design the SQL from scratch, design a query, in design grid, that do what you need.
Switch to SQL view and the SQL string will be ready to use.
 
Your attachment is showing a table not a form so you need to modify your query to work off this table - if the table is generated to create a rowsource to a combobox or listbox on the form, then use this rowsource

If are multiple low values, pick the first one
In SQL there is no real concept of 'first', you need to define it yourself by ordering the table (in this case by Checkout Order) and since you have two records with the value of 1, it could choose either one - I can see they are the same so I guess it doesn't matter which.
 
I figured out how to do it. I had to do another query where i did just the Min function the matched that query to my original query to get what I needed. I just couldn't do it all in one query like i was trying to do.
 

Users who are viewing this thread

Back
Top Bottom