Results 1 to 5 of 5
  1. #1
    aznabeel is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2015
    Posts
    5

    Get average monthly BALANCE

    on the below data i am trying to get average monthly BALANCE, based on the following query ....but i only getting all recods with actual balace and not month wise average balance of the customers......

    can any body guide me...........................

    -----------------------------------
    SELECT [customer profit].[Customer Number], AVG ([customer profit].[VAL_BAL]) AS average, Month ([customer profit].[Balance Date])
    FROM [customer profit]


    GROUP BY [customer profit].[customer Number], [customer profit].[VAL_BAL], [customer profit].[Balance Date];
    --------------------------------------
    Data

    Customer Number Balance Date VAL_BAL CCY
    40001 2/1/2014 1724.68 PKR
    10001 2/2/2014 1724.68 PKR
    40001 2/3/2014 401724.68 PKR
    30001 2/4/2014 446724.68 PKR
    40001 2/5/2014 446724.68 PKR
    40001 2/6/2014 21724.68 PKR
    10001 2/7/2014 1724.68 PKR
    40001 2/8/2014 1724.68 PKR
    20001 2/9/2014 1724.68 PKR
    40001 2/10/2014 1724.68 PKR
    20001 2/11/2014 1724.68 PKR
    40001 2/12/2014 1724.68 PKR
    30001 2/13/2014 1724.68 PKR
    40001 2/14/2014 1724.68 PKR
    40001 2/15/2014 1724.68 PKR
    30001 2/16/2014 1724.68 PKR
    40001 2/17/2014 1724.68 PKR
    40001 2/18/2014 201724.68 PKR
    10001 2/19/2014 186724.68 PKR
    40001 2/20/2014 186724.68 PKR
    30001 2/21/2014 86424.68 PKR
    40001 2/22/2014 86424.68 PKR
    20001 2/23/2014 86424.68 PKR
    40001 2/24/2014 86424.68 PKR
    40001 2/25/2014 86424.68 PKR
    10001 2/26/2014 86424.68 PKR
    40001 2/27/2014 6424.68 PKR
    20001 2/28/2014 6424.68 PKR



  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You need to group by the month, not by the whole date. You also do NOT want VAL_BAL find in your GROUP BY clause (just your Customer Number and Month).

    If it does not let you do that all in one step, you may need to either use two queries or use a nested query.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    SELECT [customer profit].[Customer Number], AVG([customer profit].[VAL_BAL]) AS average, Format([customer profit].[Balance Date], "YYYYMO") AS YrMo
    FROM [customer profit]
    GROUP BY [customer profit].[customer Number], Format([customer profit].[Balance Date], "YYYYMO");
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Uhmmm, shouldn't the format clause be

    Format([customer profit].[Balance Date], "YYYYMM")
    instead of
    Format([customer profit].[Balance Date], "YYYYMO")???

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Ooooops! Thanks Steve.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 3
    Last Post: 10-09-2014, 03:31 PM
  2. Replies: 1
    Last Post: 03-29-2014, 10:19 AM
  3. Monthly Sales reports with wholesale average
    By Yarrrm8e in forum Reports
    Replies: 3
    Last Post: 01-31-2014, 04:39 PM
  4. Replies: 6
    Last Post: 11-10-2012, 09:49 PM
  5. Replies: 13
    Last Post: 05-28-2010, 11:57 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