- SELECT [Item No] CASE WHEN (
- [Net Available Stock Quantity]+Subcon+[In Progress WIP]+CASE (
- WHEN ([Raw Material In Store] AND [Demand Material] != 0 THEN [Raw Material In Store]/[Demand Material] ELSE 0) +
- WHEN ([Outstanding Raw Material] AND [Demand Material] != 0 THEN [Outstanding Raw Material]/[Demand Material] ELSE 0) +
- [In Progress WIP]) > [Maximum Stock])
- THEN (
- [Net Available Stock Quantity]+Subcon+[In Progress WIP]+CASE (
- WHEN ([Raw Material In Store] AND [Demand Material] != 0 THEN [Raw Material In Store]/[Demand Material] ELSE 0) +
- WHEN ([Outstanding Raw Material] AND [Demand Material] != 0 THEN [Outstanding Raw Material]/[Demand Material] ELSE 0) +
- [In Progress WIP]) - [Maximum Stock])
- ELSE (
- [Net Available Stock Quantity]+Subcon+[In Progress WIP]+CASE (
- WHEN ([Raw Material In Store] AND [Demand Material] != 0 THEN [Raw Material In Store]/[Demand Material] ELSE 0) +
- WHEN ([Outstanding Raw Material] AND [Demand Material] != 0 THEN [Outstanding Raw Material]/[Demand Material] ELSE 0) +
- [In Progress WIP] < [Minimum Stock])
- THEN (
- [Minimum Stock]+[Net Available Stock Quantity]+Subcon+[Outstanding WIP]+CASE (
- WHEN ([Raw Material In Store] AND [Demand Material] != 0 THEN [Raw Material In Store]/[Demand Material] ELSE 0) +
- WHEN ([Outstanding Raw Material] AND [Demand Material] != 0 THEN [Outstanding Raw material]/[Demand Material] ELSE 0) +
- [Outstanding WIP])
- )
- END AS [Final Stock Over Max]
I don't know where and what is wrong. Tried paste to sql query, certain part higlighted as Incorrect syntax. Google syntax of SELECT CASE WHEN, i think it's all good.