-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,31 @@ | ||
# Data Cleaning | ||
|
||
## Data cleaning for customer orders table | ||
|
||
`customer_orders` tablosunda exclusions ve extras sütunlarında hem boş stringler var hem de string halinde null yazan değerler var. Amacımız bu string halindeki null değerleri ve boş string ifadeleri `NULL` değerlere dönüştürmek. Bunu yapabilmek için case when yapısı kullanıyoruz. | ||
|
||
```sql | ||
select order_id, | ||
customer_id, | ||
pizza_id, | ||
case when exclusions = 'null' or exclusions = '' then NULL else exclusions END as exclusions, | ||
case when extras = 'null' or extras = '' then NULL else extras END as extras, | ||
order_time | ||
FROM customer_orders; | ||
``` | ||
output | ||
![image](https://github.com/user-attachments/assets/c5775798-a74d-4bc9-85c7-bf79f6b170f9) | ||
|
||
istediğim tabloya ulaştığıma emin olduktan sonra tablomu güncelliyorum. Bunu da update ve set komutları ile gerçekleştiriyorum. | ||
|
||
```sql | ||
UPDATE customer_orders | ||
SET exclusions = CASE | ||
when exclusions = 'null' or exclusions = '' then NULL else exclusions | ||
END; | ||
|
||
UPDATE customer_orders | ||
SET extras = CASE | ||
when extras = 'null' or extras = '' then NULL else extras | ||
END; | ||
``` |