Michiel Soede
Registered User.
- Local time
- Today, 18:17
- Joined
- Sep 16, 2012
- Messages
- 12
All,
A very simple question but I can not wrap my head around it als having looked into some examples on different fora. I just need to deduct month 1 from month 2 (from the table fusion_entries) written by means of a sql code in Access (I know how to fix using normal queries) by joining entity cost center and account. I think I need to make a sub query on month 1 and inner join that on the main query on month 2. But some how it does not work and also not sure if I need to use a sub query. There might be quite some transactions so efficiency also comes into play. Hopefully somebody can share his expertise around this.
Thanks in advance,
Michiel
Code so far without sub query and in the attachment the simplified table:
A very simple question but I can not wrap my head around it als having looked into some examples on different fora. I just need to deduct month 1 from month 2 (from the table fusion_entries) written by means of a sql code in Access (I know how to fix using normal queries) by joining entity cost center and account. I think I need to make a sub query on month 1 and inner join that on the main query on month 2. But some how it does not work and also not sure if I need to use a sub query. There might be quite some transactions so efficiency also comes into play. Hopefully somebody can share his expertise around this.
Thanks in advance,
Michiel
Code so far without sub query and in the attachment the simplified table:
Code:
SELECT c.ENTITY, c.COST_CENTRE, c.ACCOUNT, c.ACCOUNTED_TOT AS Jan, d.ACCOUNTED_TOT AS Feb
FROM TBL_FUSION_ENTRIES AS c INNER JOIN (SELECT ENTITY, COST_CENTRE, ACCOUNT, ACCOUNTED_TOT FROM TBL_FUSION_ENTRIES WHERE [PERIOD_NUM] = '2') AS d ON c.COST_CENTRE = d.COST_CENTRE
WHERE c.PERIOD_NUM = '1';