Case Statement after a Union

General

Case Statement after a Union

Hi everyone, 

Sorry for my English. I´m not good writer.

Well, I made a Union

SELECT  CUSTOMER_REF_NAM as CustRef FROM SaleOrder;

Union 

SELECT CUSTOMER_REF_NAM as CustRef FROM AL1;

After that I need created a computed field about the CustRef. I thought in a case statement but I do not know how implement.

Any suggestion 

Tags (2)
1 REPLY
Enthusiast

Re: Case Statement after a Union

Make sure your select lists are same length and datatype.

SELECT  CUSTOMER_REF_NAM AS CustRef, CASE WHEN cust_ref = 'X' THEN 'value' END FROM SaleOrder
UNION
SELECT CUSTOMER_REF_NAM AS CustRef , CASE WHEN cust_ref = 'X' THEN 'value' END FROM AL1;

Rglass