THEN
satser i CASE
uttrycket är felaktigt:
CASE WHEN SUM(L55.TOTAL_QUANTITY - BC.FULLBOX * L55.PACKING_STYLE) = 0
THEN L55.SPAREBOX = 0
----------^
WHEN SUM(L55.TOTAL_QUANTITY - BC.FULLBOX * L55.PACKING_STYLE) != 0
THEN L55.SPAREBOX = 1
END AS SPARE_QUANTITY
Oracle har ingen boolesk datatyp i SELECT
frågor.
Jag gissar att du bara vill:
(CASE WHEN SUM(L55.TOTAL_QUANTITY - BC.FULLBOX * L55.PACKING_STYLE) = 0
THEN 0
WHEN SUM(L55.TOTAL_QUANTITY - BC.FULLBOX * L55.PACKING_STYLE) <> 0
THEN 1
END) AS SPARE_QUANTITY
Eller, om du vill ta bort CASE
:
ABS(SIGN(SUM(L55.TOTAL_QUANTITY - BC.FULLBOX * L55.PACKING_STYLE))) AS SPARE_QUANTITY