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