Hi there
I need some source code help please. I need to aggregate some self referencing records. Each record in my database has a parent, but this is a flat structure. The genesis records will have a parentid=0, and their children have parentid=genesisid etc etc
For example,
id=1,wbs=1,parentid=0,startdate=2018-03-10,finishdate=2018-03-31,progress=10,budget=20
id=2,wbs=2,parentid=0,startdate=2018-03-10,finishdate=2018-03-31,progress=10,budget=30
id=3,wbs=3,parentid=0,startdate=2018-01-11,finishdate=2018-03-31,progress=10,budget=100
id=4,wbs=3.1,parentid=3,startdate=2018-03-10,finishdate=2018-03-31,progress=2,budget=200
id=5,wbs=2.2,parentid=2,startdate=2018-02-01,finishdate=2018-03-31,progress=1,budget=500
id=6,wbs=5.1,parentid=5,startdate=2018-02-01,finishdate=2018-03-31,progress=0,budget=400
Now what I want to do is
Now, there can be a lot of parents and a lot of children here in the same db table. I need some simple methodology and perhaps source to do this please.
Thanks a lot!
I need some source code help please. I need to aggregate some self referencing records. Each record in my database has a parent, but this is a flat structure. The genesis records will have a parentid=0, and their children have parentid=genesisid etc etc
For example,
id=1,wbs=1,parentid=0,startdate=2018-03-10,finishdate=2018-03-31,progress=10,budget=20
id=2,wbs=2,parentid=0,startdate=2018-03-10,finishdate=2018-03-31,progress=10,budget=30
id=3,wbs=3,parentid=0,startdate=2018-01-11,finishdate=2018-03-31,progress=10,budget=100
id=4,wbs=3.1,parentid=3,startdate=2018-03-10,finishdate=2018-03-31,progress=2,budget=200
id=5,wbs=2.2,parentid=2,startdate=2018-02-01,finishdate=2018-03-31,progress=1,budget=500
id=6,wbs=5.1,parentid=5,startdate=2018-02-01,finishdate=2018-03-31,progress=0,budget=400
Now what I want to do is
- Sum: sum the budgets of children per parents and put the sum as the budget amount for parents
- Min & Max: find the minimum and maximum dates for the children and put this for parents.
- Average: find the average progress for children and put on for parents
Now, there can be a lot of parents and a lot of children here in the same db table. I need some simple methodology and perhaps source to do this please.
Thanks a lot!