Join Our 5-Week ML/AI Engineer Interview Bootcamp 🚀 led by ML Tech Leads at FAANGs
How would you replace null or missing payment_method values with "unknown" in appstore_transactions and return all columns ordered by user_id ascending and transaction_dt descending?
| Column Name | Type |
|---|---|
| transaction_id | int64 |
| user_id | int64 |
| app_name | object |
| transaction_dt | object |
| payment_method | object |
| price | float64 |
| device | object |
| rating | float64 |
| Column Name | Type |
|---|---|
| transaction_id | int64 |
| user_id | int64 |
| app_name | object |
| transaction_dt | datetime64[ns] |
| payment_method | object |
| price | float64 |
| device | object |
| rating | float64 |
Keep all columns in output
Sort: user_id asc, transaction_dt desc
Look for a SQL function that replaces NULLs in a single column with a constant string.
Use COALESCE(payment_method, 'unknown') to replace missing values.
After replacing nulls, sort with ORDER BY user_id ASC, transaction_dt DESC.