Results 1 to 3 of 3
  1. #1
    claytoncramer is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2020
    Posts
    7

    grouping by decade

    I need to sum numbers in a field by decade.



    Incidents table has year field and dead fields. I have been given this SQL query that supposedly does that:
    Code:
    select incident.dead as dead, incident_date as year 
    from  (select int(year('incident_date') / 10 * 10) as decade from  incidents) from incidents
    group by decade;
    '

    but it complains about the outer FROM clause.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    More like

    select Sum(incident.dead) as Totaldead, int(year('incident_date') / 10 * 10) as decade
    from incidents
    group by int(year('incident_date') / 10 * 10);

    Though I haven't checked the math, just the syntax.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    put the decade in the query. then group the rpt on it.

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

Similar Threads

  1. Grouping
    By mike60smart in forum Queries
    Replies: 9
    Last Post: 02-20-2020, 08:26 AM
  2. Grouping
    By Yewee in forum Reports
    Replies: 12
    Last Post: 07-05-2017, 12:52 PM
  3. Grouping
    By McArthurGDM in forum Queries
    Replies: 3
    Last Post: 08-11-2014, 03:56 PM
  4. Help with grouping
    By RachelBedi in forum Queries
    Replies: 1
    Last Post: 11-05-2012, 12:55 PM
  5. Grouping
    By EricF in forum Reports
    Replies: 5
    Last Post: 07-18-2011, 03:58 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