Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

IF STATEMENT WITH A CASE STATEMENT WITHIN A SQL SELECT

$
0
0

    SELECT CASE STATUS WHEN 'WO' THEN ISNULL(REPLACE(TempWOID, '~', '') , '')  ELSE CAST(INVOICE AS NVARCHAR(20)) END AS INVOICE,
A.CUSTOMER, CAST(A.CUSTOMER AS NVARCHAR(50)) AS CUSTOMERSTRING, C.NAME, SHIPPED, D.Name AS DRIVER, ARHID,--ISNULL(A.TempWOID,'') AS TEMPWOID,
SUBTOTAL + TAXES AS PRICE, IF (STATUS = 'AR')THEN CASE INVTYPE
WHEN 'REG' THEN 'inv' 
WHEN 'RET' THEN 'ret' 
WHEN 'REF' THEN 'cre' 
END 
ELSE STATUS
AS STATUS, ......

THE IF STATEMENT IS GIVING ME AN ERROR HOW WOULD I DO IT?


Debra has a question


Viewing all articles
Browse latest Browse all 23857

Trending Articles