Home > Mobile >  Rounding Up Number to the Nearest Value on Another Table
Rounding Up Number to the Nearest Value on Another Table

Time:06-20

is this something that's possible to achieve in Ms. Access?

I have two table, first table is a calculated product requirement:

enter image description here

Second Table is the fixed adjusted rate specific to each product (since there's a fix output rate from the equipment we used to apply the product and have to split them in a very specific rate)

enter image description here

The goal would be to generate this table (so I can link it to the table 2 and get a specific split rate required by the equipment)

enter image description here

I have been cranking my head for hours but couldn't find a solution yet. Any help would be appreciated :)

CodePudding user response:

Consider:

SELECT Table1.*, Table2.* FROM Table1
INNER JOIN Table2 ON Table1.Product = Table2.Product 
WHERE Table2.Adjusted = (SELECT TOP 1 Adjusted FROM Table2 
                         WHERE Table1.Calculated <= Table2.Adjusted);

CodePudding user response:

You can also try below query-

Select t.product, MIN(t.adjusted) as Adjusted from 
    (SELECT t1.Product, t2.Adjusted
    FROM Table1 as t1 INNER JOIN Table2 as t2 ON t1.Product = t2.Product
    WHERE (t2.Adjusted>t1.calculated)) as t Group by t.Product;

enter image description here

  • Related