Not sure if such functionality exists but I’m curious if I have the following DB as shown below, if it can be updated such that wherever first_name and last_name match all deduction and pay columns are added together, and thus a single line formed. I know a query can be written to get me such information, but I need this query result to actually become the database. (i.e. cleaning superfluous extra lines sort to speak).
i.e.
first_name | last_name | deduction | pay
skywalker | luke | 100 | 200
vader | darth | 50 | 100
skywalker | luke | 400 | 500
becomes
first_name | last_name | deduction | pay
skywalker | luke | 500 | 700
vader | darth | 50 | 100
Thanks for the help/advice!
Answer 1
Create a trigger and another table
You could create a table called star_wars and another called star_wars_roll_up. Then a trigger on star_wars that aggregate data to star_wars_roll_up. You write to star_wars and read from star_wars_roll_up. It is safe to delete anything from star_wars whenever you feel like it.