Solved How to check for nearest approx number (1 Viewer)

Kayleigh

Member
Local time
Today, 13:02
Joined
Sep 24, 2020
Messages
706
Hi,

I have a database which calculates quotes for materials required based on the measurements entered (length and width).
They now would like to include a table with what they currently have in stock.
Then when entering the measurements it should check in the stock table if any length/width are within 20mm.

Any suggestions on how to design the logic here?

Ps. On further consideration I'm thinking along the lines of iterating through the table after update of measurements and checking if each is more or less than 20mm. Is this the best option?
 
Last edited:

CJ_London

Super Moderator
Staff member
Local time
Today, 13:02
Joined
Feb 19, 2013
Messages
16,616
without knowing the table design I would speculate something like

select *
from tblstock where length between requiredlength-20 and required length+20
And width between requiredwidth-20 and requiredwidth+20
 

moke123

AWF VIP
Local time
Today, 08:02
Joined
Jan 11, 2013
Messages
3,920
Not sure what your stock consists of but shouldn't there be a third dimension like depth or thickness?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 07:02
Joined
Feb 28, 2001
Messages
27,191
I'm not sure what line of work you are in, but for construction, "shorts" are not useful. You need exact-measure or longer. You can always take a longer piece and make it shorter. You can't take a shorter piece and make it longer. So can you explain what kind of business this is that allows "shorts"?
 

Users who are viewing this thread

Top Bottom