April 17, 2011 at 11:37 pm
Hi experts,
CASE WHEN ORDER.CATEGORY_CODE = 'RETURN' THEN
(NVL(ORDER.ORDERED_QUANTITY,0) - NVL(ORDER.SHIPPED_QUANTITY,0) ) *-1
ELSE
(NVL(ORDER.ORDERED_QUANTITY,0) - NVL(ORDER.SHIPPED_QUANTITY,0) )
END Qty,
It is my oracle case statement,i have to write same functionality in sqlserver 2005,how can i write? please help on this
Thanks
venki
April 17, 2011 at 11:42 pm
The Case looks ok, but NVL is not a SQL function. What does it do?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 18, 2011 at 12:03 am
In Place of NVL just replace with COALESCE
CASE WHEN ORDER.CATEGORY_CODE = 'RETURN' THEN
(COALESCE(ORDER.ORDERED_QUANTITY,0) - COALESCE(ORDER.SHIPPED_QUANTITY,0) ) *-1
ELSE
(COALESCE(ORDER.ORDERED_QUANTITY,0) - COALESCE(ORDER.SHIPPED_QUANTITY,0) )
END Qty,
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply