I have a SQLite table like this:
| id | item | totalcost | sharedppl | paidby | second | third |
|---|---|---|---|---|---|---|
| 1 | Lunch | 150 | 3 | Tom | Jack | Harry |
| 2 | Dinner | 200 | 2 | Jack | Harry | |
| 3 | Drinks | 75 | 3 | Harry | Jack | Tom |
I want a new SQLite table to show share of each person. It needs to do the calculation to split the cost for each item between the people.
| item | Tom | Jack | Harry |
|---|---|---|---|
| Lunch | 50 | 50 | 50 |
| Dinner | 0 | 100 | 100 |
| Drinks | 25 | 25 | 25 |
Please advise what query I need to run on sql to get this new table.