Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    67

    Unanswered: Grouping records by month

    I have a Query that contains something like the following:

    Field1
    A
    A
    A
    B
    B
    B
    B
    C
    C
    C

    Field2
    Month1
    Month2
    Month1
    Month2
    Month3
    etc.

    I am trying to get a Query to look like this

    Field3
    Month1
    Month2
    Month3
    etc.

    Field4
    Sum of A, B, and C (i.e. for Month1)
    Sum of A, B, and C (i.e. for Month2)
    Sum of A, B, and C (i.e. for Month3)
    etc.

    Can this be done via another Query? I assume it can be done with Pivot Tables but am not very knowledgeable about Pivot Tables.

    Thank you for any help.

    Jim

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    SELECT SUM(A), SUM(B), SUM(C) FROM SomeTable GROUP BY MonthField;

    -or-

    SELECT SUM(A+B+C) FROM SomeTable GROUP BY MonthField;
    Back to Access ... ADO is not the way to go for speed ...

  3. #3
    Join Date
    Feb 2004
    Posts
    67

    Thank you

    M Owen,

    Thanks much for the SQL statement. I am pretty new to SQL and Access Queries. Can you help with how I insert the SQL statement into a Query?

    I know how to get into "SQL View", but that's about it.

    How do I relate the SQL statement to a Query field. Do I create a new Query that relates to what you have called "SomeTable" and contains my "A", "B", and "C" records? And then include your statement as a field expression? Or, do I need to include your statement in a VB module and create a Query with your statement?

    Thanks again for your help.

    Jim

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •