-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReplacing NULL values.sql
36 lines (36 loc) · 1.72 KB
/
Replacing NULL values.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
CREATE TABLE prod_Churn AS
SELECT
Customer_ID,
Gender,
Age,
Married,
State,
Number_of_Referrals,
Tenure_in_Months,
IF(Value_Deal IS NULL OR TRIM(Value_Deal) = '', 'None', Value_Deal) AS Value_Deal,
Phone_Service,
IF(Multiple_Lines IS NULL OR TRIM(Multiple_Lines) = '', 'No', Multiple_Lines) AS Multiple_Lines,
Internet_Service,
IF(Internet_Type IS NULL OR TRIM(Internet_Type) = '', 'None', Internet_Type) AS Internet_Type,
IF(Online_Security IS NULL OR TRIM(Online_Security) = '', 'No', Online_Security) AS Online_Security,
IF(Online_Backup IS NULL OR TRIM(Online_Backup) = '', 'No', Online_Backup) AS Online_Backup,
IF(Device_Protection_Plan IS NULL OR TRIM(Device_Protection_Plan) = '', 'No', Device_Protection_Plan) AS Device_Protection_Plan,
IF(Premium_Support IS NULL OR TRIM(Premium_Support) = '', 'No', Premium_Support) AS Premium_Support,
IF(Streaming_TV IS NULL OR TRIM(Streaming_TV) = '', 'No', Streaming_TV) AS Streaming_TV,
IF(Streaming_Movies IS NULL OR TRIM(Streaming_Movies) = '', 'No', Streaming_Movies) AS Streaming_Movies,
IF(Streaming_Music IS NULL OR TRIM(Streaming_Music) = '', 'No', Streaming_Music) AS Streaming_Music,
IF(Unlimited_Data IS NULL OR TRIM(Unlimited_Data) = '', 'No', Unlimited_Data) AS Unlimited_Data,
Contract,
Paperless_Billing,
Payment_Method,
Monthly_Charge,
Total_Charges,
Total_Refunds,
Total_Extra_Data_Charges,
Total_Long_Distance_Charges,
Total_Revenue,
Customer_Status,
IF(Churn_Category IS NULL OR TRIM(Churn_Category) = '', 'Others', Churn_Category) AS Churn_Category,
IF(Churn_Reason IS NULL OR TRIM(Churn_Reason) = '', 'Others', Churn_Reason) AS Churn_Reason
FROM
stg_Churn;