Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have the following SQL. it works fine. I just need to add more logic to it sel

ID: 3749278 • Letter: I

Question

I have the following SQL. it works fine. I just need to add more logic to it

select

CASE WHEN supplier_std_pack IS NULL THEN [supplier_min_fab1] ELSE (ceiling(supplier_min_fab1 / supplier_std_pack ) * supplier_std_pack)
END as supplier_min_fab1

from inventory_supplier_ud

I need to add in logic w/ a new field(recommended_qty) in the SQL statement, but ending in the same column (end as supplier_min_fab1).

stating IF the supplier_min_fab1 is less than recommended_qty, then (ceiling(recommended_qty/supplier_std_pack) * supplier_std_pack) end as supplier_min_fab1, otherwise run it like it how it is.

Explanation / Answer

select

CASE

WHEN supplier_std_pack IS NULL THEN [supplier_min_fab1]

WHEN supplier_min_fab1 < recommended_qty THEN (ceiling(recommended_qty/supplier_std_pack) * supplier_std_pack)

ELSE (ceiling(supplier_min_fab1 / supplier_std_pack ) * supplier_std_pack)

END as supplier_min_fab1

from inventory_supplier_ud;