Hello,
I am trying to create a GroupBy query with Sum() and having dramas getting my head around things.
Scenario:
Laundromat, machines, based on cash. Cash cleared say weekly (Could be more or less often).
1 clear = coins + notes, all great. A single clear for the week is say $47 coins + 100 notes = $147 for the clear, for a given date / machine of say 8 Mar 2017. This is stored in a table tblCashClearances.
Introduce credit card (New technology) - now I have the maybe same $147 cash (Coin + note) sales for the week, and a bunch of card transactions in between. In other words, if the last a cash clearance was done on 1 Mar 2017, then the next on 8 Mar 2017, I may have card transactions for:
27 Feb 2017 2.11pm for $7.60,
2 Mar 2017 11:57am for $5.20,
3 Mar 2017 2:15pm for $6.80,
7 Mar 2017 3:45pm for $2.90
and so on. These card transactions are imported into my db to a tblCardTransactions table from csv files from the card supplier.
What I need to see, is the total sales per CashClearance - this should include the once off coin + notes, plus any CardTransactions since the last cash clear.
With the above numbers, I should have
Machine ClearDate Coin Notes Card Total
XYZ 8 Mar 2017 $47.00 $100.00 $14.90 $164.90
I start off looking at a GroupBy query with a Sum(CardTransactions.TransactionAmount) per CashClearance, then get bogged in the detail. I am currently trying to create a UNION query first (All card + cash), then GroupBy on this query.
I am generally ok on queries, it seems getting stuck on where to start here rather than the query detail (I think...).
Any comments appreciated.
Thanks in advance
swas