By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
| id | namename | referredby |
|---|---|---|
| 1 | John | null |
| 2 | Jane | null |
| 3 | Anne | 2 |
| 4 | Eric | null |
| 5 | Pat | 1 |
| id | Billingdate | customerid |
|---|---|---|
| 1 | 2023-10-01 | 1 |
| 2 | 2023-10-15 | 2 |
| 3 | 2023-11-05 | 1 |
| 4 | 2023-11-20 | 3 |
| 5 | 2023-12-01 | 2 |
| id | Billingdate | customerid | id | namename | referredby |
|---|---|---|---|---|---|
| 1 | 2023-10-01 | 1 | 1 | John | null |
| 2 | 2023-10-15 | 2 | 2 | Jane | null |
| 3 | 2023-11-05 | 1 | 1 | John | null |
| 4 | 2023-11-20 | 3 | 3 | Anne | 2 |
| 5 | 2023-12-01 | 2 | 2 | Jane | null |
| id | Billingdate | CustomerName | referredby | referral_name |
|---|---|---|---|---|
| 1 | 2023-10-01 | John | null | null |
| 2 | 2023-10-15 | Jane | null | null |
| 3 | 2023-11-05 | John | null | null |
| 4 | 2023-11-20 | Anne | 2 | Jane |
| 5 | 2023-12-01 | Jane | null | null |