Discussion:
SubQuery Totaling Specific Subset of Records
(too old to reply)
dallin
2009-12-02 20:15:01 UTC
Permalink
Can someone give me some hints on how to write a query that does the
following -- I'm having a hard time subtotaling by period end date any sale
date record that is 60 days less than the period end date.

Co PED Sale date TaxCredit
1 12/31/08 10/31/08 15.00
1 12/31/08 10/31/08 12.00
1 12/31/08 09/30/08 5.00
9 01/31/09 11/30/08 10.15
9 01/31/09 11/30/08 21.15
9 01/31/09 09/30/08 10.02

Query Result should look like:
Co PED SaleDate TaxCredit
1 12/31/08 10/31/08 27.00
9 01/31/09 11/30/08 31.30
Alex Dybenko
2009-12-03 15:32:34 UTC
Permalink
Hi,
try this:

SELECT Co, PED, [Sale date], Sum(TaxCredit)
FROM MyTable
GROUP BY Co, PED, [Sale date]
--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com
Post by dallin
Can someone give me some hints on how to write a query that does the
following -- I'm having a hard time subtotaling by period end date any sale
date record that is 60 days less than the period end date.
Co PED Sale date TaxCredit
1 12/31/08 10/31/08 15.00
1 12/31/08 10/31/08 12.00
1 12/31/08 09/30/08 5.00
9 01/31/09 11/30/08 10.15
9 01/31/09 11/30/08 21.15
9 01/31/09 09/30/08 10.02
Co PED SaleDate TaxCredit
1 12/31/08 10/31/08 27.00
9 01/31/09 11/30/08 31.30
Loading...