G
Glint
Hi All,
I have a query that goes like this:
SELECT ExpenseItems.Expenditure, Sum(IIf(IsNull([ItemAmount]) Or
[ItemAmount]<0,0,[ItemAmount])) AS Income, Sum(IIf(IsNull([ItemAmount]) Or
[ItemAmount]>0,0,[ItemAmount])) AS Expense, Sum(Nz([ItemAmount],0)) AS Balance
FROM ExpenseItems LEFT JOIN vBalances ON ExpenseItems.ExpenditureID =
vBalances.Summary
GROUP BY ExpenseItems.Expenditure;
This returns the totals for all records for each item in the Expenditure
column.
Now I want to add another income column that returs only select records
based on the dates of an opened form. The new Income Column could be like
this:
SELECT vBalances.Summary, Sum(vBalances.ItemAmount) AS Income1
FROM vBalances
WHERE (((vBalances.TDate)<=[Forms]![CashBook]![Starting]))
GROUP BY vBalances.Summary;
This returns totals for each item in the Summary column (which is equal to
the Expenditure column above) depending on the dates of the CashBook form.
The problems is how to incorporate the Income1 column into the first query.
I have not been able to get the syntax of the subquery right.
I have a query that goes like this:
SELECT ExpenseItems.Expenditure, Sum(IIf(IsNull([ItemAmount]) Or
[ItemAmount]<0,0,[ItemAmount])) AS Income, Sum(IIf(IsNull([ItemAmount]) Or
[ItemAmount]>0,0,[ItemAmount])) AS Expense, Sum(Nz([ItemAmount],0)) AS Balance
FROM ExpenseItems LEFT JOIN vBalances ON ExpenseItems.ExpenditureID =
vBalances.Summary
GROUP BY ExpenseItems.Expenditure;
This returns the totals for all records for each item in the Expenditure
column.
Now I want to add another income column that returs only select records
based on the dates of an opened form. The new Income Column could be like
this:
SELECT vBalances.Summary, Sum(vBalances.ItemAmount) AS Income1
FROM vBalances
WHERE (((vBalances.TDate)<=[Forms]![CashBook]![Starting]))
GROUP BY vBalances.Summary;
This returns totals for each item in the Summary column (which is equal to
the Expenditure column above) depending on the dates of the CashBook form.
The problems is how to incorporate the Income1 column into the first query.
I have not been able to get the syntax of the subquery right.