Results 1 to 8 of 8
  1. #1
    shak2 is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    23

    Group query results

    I have a query, this is the code I used to get what I wanted:

    SELECT [Master Approved Days].[Date], [Master Approved Days].[Record Number], [Master Approved Days].[Approved Days 1], Count([Master Approved Days].[Approved Days 1]) AS [CountOfApp Days]
    FROM [Master Approved Days]
    GROUP BY [Master Approved Days].[Date], [Master Approved Days].[Record Number], [Master Approved Days].[Approved Days 1];

    The [Approved Days 1] field lists all possible durations, so from 1, 2, 3, 4, through '>7.' I want to put a grouping/clause in my code so that I can split this range into <=3, >3 days, and have the query count all those greater than 3, and less than or equal to 3.

    Any ideas?

  2. #2
    Sal_v is offline Novice
    Windows XP Access 2010 (version 14.0)
    Join Date
    Sep 2010
    Posts
    4
    Create two fields (xx and kount):
    xx:IIf([Approval_days]>3,">3","<=3")
    kount:Count([Approval_days])
    Group on xx

    SELECT IIf([Approval_days]>3,">3","<=3") AS xx, Count(tblMstrAppDays.[Approval_days]) AS kount
    FROM tblMstrAppDays
    GROUP BY IIf([Approval_days]>3,">3","<=3");

  3. #3
    shak2 is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    23
    Quote Originally Posted by Sal_v View Post
    Create two fields (xx and kount):
    xx:IIf([Approval_days]>3,">3","<=3")
    kount:Count([Approval_days])
    Group on xx

    SELECT IIf([Approval_days]>3,">3","<=3") AS xx, Count(tblMstrAppDays.[Approval_days]) AS kount
    FROM tblMstrAppDays
    GROUP BY IIf([Approval_days]>3,">3","<=3");
    I keep getting syntax error on this part of the statement:
    xx:IIf([Approval_days]>3,">3","<=3")
    kount:Count([Approval_days])
    Group on xx
    It keeps saying that i'm missing an operator

  4. #4
    shak2 is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    23
    Quote Originally Posted by Sal_v View Post
    Create two fields (xx and kount):
    xx:IIf([Approval_days]>3,">3","<=3")
    kount:Count([Approval_days])
    Group on xx

    SELECT IIf([Approval_days]>3,">3","<=3") AS xx, Count(tblMstrAppDays.[Approval_days]) AS kount
    FROM tblMstrAppDays
    GROUP BY IIf([Approval_days]>3,">3","<=3");

    ok this isn't working period. It makes no sense

  5. #5
    Sal_v is offline Novice
    Windows XP Access 2010 (version 14.0)
    Join Date
    Sep 2010
    Posts
    4
    I'm getting an error uploading the db. send me an email (via pm)

  6. #6
    shak2 is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    23
    I have no idea what you're talking about.

  7. #7
    Sal_v is offline Novice
    Windows XP Access 2010 (version 14.0)
    Join Date
    Sep 2010
    Posts
    4
    let me re-phrase it, I cannot upload a database with an example/solution. If you want the db, send me a pm(private message through the forum) with your email so I can send you the db directly.

  8. #8
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Shak2:
    If you provide an example, we can understand you much better and easier.

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

Similar Threads

  1. Replies: 6
    Last Post: 05-14-2012, 07:24 AM
  2. SQL query with SUM, INNER JOIN and GROUP BY
    By BayerMeister in forum Queries
    Replies: 2
    Last Post: 08-14-2010, 12:55 AM
  3. Group by Week in a Crosstab Query
    By NMJones in forum Access
    Replies: 1
    Last Post: 06-24-2010, 04:09 PM
  4. query group by
    By fanfan2 in forum Queries
    Replies: 3
    Last Post: 03-12-2010, 03:07 PM
  5. columns for group detail but not group header?
    By Coolpapabell in forum Reports
    Replies: 0
    Last Post: 08-21-2009, 08:53 AM

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