I have two tables (inputs and categories):
CREATE TABLE categories (
iId INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
sName TEXT NOT NULL,
iParent INTEGER,
FOREIGN KEY (iParent) REFERENCES categories(iId)
);
CREATE TABLE inputs (
iId INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
iCategory INTEGER,
dValue DOUBLE NOT NULL,
FOREIGN KEY (iCategory) REFERENCES categories(iId)
);
I need get the sums(dValue column) from inputs table for each category. Even if the sum result is zero.
If is it possible would be better if I could get the sum for each Parent Category ( when categories.iId = categories.iParent, summing the results of the child categories to the parent category )
Can anyone help me? I appreciate any help!
Thanks!
Try this:
EDIT : With accounts: