You can't mix results of a CASE
statement, that means you can't return an INT
under one condition and a VARCHAR
in another. If you want to return Returned
then you will need to CONVERT
or CAST
your numeric values to VARCHAR
You also have a syntactical problem with your CASE.
You'd have to change it to something like this:
CASE X.RECEIVED_QTY
WHEN 0 THEN CAST( FLOOR(SYSDATE-INVENTORY_TRANS.TRANSACTION_DATE) AS VARCHAR(20))
ELSE 'RETURNED'
END AS DAYS_OUT