Results 1 to 5 of 5
  1. #1
    Adele is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    12

    Query group by month and sum

    Hi guys,



    In my query in design view I have managed to pull through all the values for each month in 2011, by putting the following in the date field:

    Like "**/01/2011"
    Like "**/01/2011"
    Etc.

    This field is hidden, I have added another identical field with no Like instances to view the results, however I need to group the results so they don’t read:

    100 04/01/2011
    170 18/01/2011
    90 02/02/2011
    160 15/02/2011

    And appear as:

    270 01/2011
    250 02/2011

    In addition to this I need another field that sums the value of the months.

    Many thanks,

    Adele x
    Last edited by Adele; 07-13-2011 at 09:09 AM.

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    Create a second query using the first one as the record source.

    Here is the SQL statement for the second query.
    Code:
    SELECT Sum(t1.tValue) AS SumOftValue, Month([tdate]) & "/" & Year([tdate]) AS tdate1
    FROM t1
    GROUP BY Month([tdate]) & "/" & Year([tdate]);
    where t1 is the name of your first query, tvalue is the values field and tdate is the date field. Change them to the names of your fields.

    Alan

  3. #3
    Adele is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    12
    fantastic i'm sure that would work great however im very new to access and work in design view alone and don't really get coding... ...is there any chance you could offer instructions for a query design view?
    thanks

  4. #4
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    No problem, but as a point of information. You can always see the SQL statement even when you produce your query in design view. In the upper right hand corner where you change from design view to datasheet view, click on the SQL view. Having said that, look at the attached and you can see what I did in the design view.

    Alan

  5. #5
    Adele is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    12
    thank you very much!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. query group by over another group by?
    By gap in forum Queries
    Replies: 2
    Last Post: 07-04-2011, 12:59 AM
  2. Group by "Month"
    By kwooten in forum Reports
    Replies: 1
    Last Post: 06-29-2011, 12:37 PM
  3. How to group by month
    By okrobie in forum Queries
    Replies: 4
    Last Post: 06-09-2011, 04:41 AM
  4. Track capacity changes month by month
    By Nils in forum Database Design
    Replies: 1
    Last Post: 02-18-2011, 03:03 PM
  5. Replies: 5
    Last Post: 11-15-2010, 06:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums