- Connect to Teradata Database using SQLA or Studio.
- Let's try to find pre-paid and post-paid customers based on the connection_type code column; the connection_type=1 would be Pre-paid and connection_type=2 would be post-paid:
/*Select for CASE*/
SELECT
cust_id,
Cust_Add,
CASE WHEN Connection_type=1 THEN 'Pre-paid'
WHEN Connection_type=2 THEN 'Post-paid'
ELSE 'Not Sure'
END AS Connection_type
FROM CUST_Type;
- Let's check the output of the following:
cust_id Cust_add Connection_type
----------- ----------- -----------
10 bal Pre-paid
21 86 court Post-paid
31 62 st Post-paid
32 21 rd Pre-paid
102 271 main Post-paid
082 10sroad Pre-paid
23 jh1-0s Not Sure