Let's say I have a table with the ids of my clients, which streaming platform they are subscribers to and how often they pay for their subscription:
user_info
+------+------------------+---------------------+
| id | subscription_plan| payment_frequency |
+------+------------------+---------------------+
| 3004 | Netflix | Monthly |
| 3004 | Disney + | Monthly |
| 3004 | Netflix | Null |
| 3006 | Star + | Yearly |
| 3006 | Apple TV | Yearly |
| 3006 | Netflix | Monthly |
| 3006 | Star + | Null |
| 3009 | Apple TV | Null |
| 3009 | Star + | Monthly |
+------+------------------+---------------------+
The problem is that I have some duplicate values, and I need to get rid of the ones that are duplicate and where the status on the payment_frequency is null. If payment_frequency is null but the record is not duplicated, this is fine, like for example ID 3009 for Apple TV.
I could simple remove all the nulls from the payment_frequency table, but that's not the ideal, as the only reason where a null is worthless for me is when it's coming from a duplicated id and subscription_plan. How do I make sure I get rid of the nulls if they match those requirements?
The result I need:
user_info
+------+------------------+---------------------+
| id | subscription_plan| payment_frequency |
+------+------------------+---------------------+
| 3004 | Netflix | Monthly |
| 3004 | Disney + | Monthly |
| 3006 | Star + | Yearly |
| 3006 | Apple TV | Yearly |
| 3006 | Netflix | Monthly |
| 3009 | Apple TV | Null |
| 3009 | Star + | Monthly |
+------+------------------+---------------------+
Thanks