Results 1 to 7 of 7
  1. #1
    mountainclimber is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    56

    Aggregate value for each group by

    I'm looking to return different average values for each GICS Sector using this query:

    Code:
    SELECT [GICS Sector], DAvg("GM","tbl0"," [GICS Sector] =  [GICS Sector] AND GM Is Not Null") AS GmMedianByGicsSectorFROM tbl0
    WHERE [GICS Sector] =  [GICS Sector]
    GROUP BY [GICS Sector];
    However, I am getting the same value for each:

    GICS Sector GmMedianByGicsSector
    Consumer Discretionary 0.469556278179105
    Consumer Staples 0.469556278179105
    Energy 0.469556278179105


    Financials 0.469556278179105
    Health Care 0.469556278179105
    Industrials 0.469556278179105
    Information Technology 0.469556278179105
    Materials 0.469556278179105
    Telecommunication Services 0.469556278179105
    Utilities 0.469556278179105

    Can someone help? Thanks.
    Last edited by mountainclimber; 07-07-2015 at 12:29 PM. Reason: typo

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    why do you have
    WHERE [GICS Sector] = [GICS Sector]
    ?
    makes no sense.

  3. #3
    mountainclimber is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    56
    Quote Originally Posted by ranman256 View Post
    why do you have
    WHERE [GICS Sector] = [GICS Sector]
    ?
    makes no sense.
    Trying stuff to get it to work. Looking for unique averages for reach GICS Sector subset...

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Air code .... might try
    Code:
    SELECT [GICS Sector], DAvg("GM","tbl0") AS GmMedianByGicsSector
    FROM tbl0
    WHERE [GM] Is Not Null
    GROUP BY [GICS Sector];
    or
    Code:
    SELECT [GICS Sector], DAvg("GM","tbl0","[GM] Is Not Null") AS GmMedianByGicsSector
    FROM tbl0
    GROUP BY [GICS Sector];


    Looking at your original query, "DAvg("GM","tbl0"," [GICS Sector] = [GICS Sector] AND GM Is Not Null")", the criteria evaluates to

    [GICS Sector] = [GICS Sector] AND GM Is Not Null
    True .......................................... (the number)
    So the criteria is "TRUE", which would avg all of the data for each [GICS Sector].


    BTW, I would advise not using spaces in object names....just causes you headaches...

  5. #5
    mountainclimber is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    56
    Quote Originally Posted by ssanfu View Post
    Air code .... might try
    Code:
    SELECT [GICS Sector], DAvg("GM","tbl0") AS GmMedianByGicsSector
    FROM tbl0
    WHERE [GM] Is Not Null
    GROUP BY [GICS Sector];
    or
    Code:
    SELECT [GICS Sector], DAvg("GM","tbl0","[GM] Is Not Null") AS GmMedianByGicsSector
    FROM tbl0
    GROUP BY [GICS Sector];


    Looking at your original query, "DAvg("GM","tbl0"," [GICS Sector] = [GICS Sector] AND GM Is Not Null")", the criteria evaluates to

    [GICS Sector] = [GICS Sector] AND GM Is Not Null
    True .......................................... (the number)
    So the criteria is "TRUE", which would avg all of the data for each [GICS Sector].


    BTW, I would advise not using spaces in object names....just causes you headaches...

    I tried all three suggestions and got the same result as my original post.

  6. #6
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,746
    What is this suppose to mean?

    Code:
    [GICS Sector] =  [GICS Sector]
    Where does the value for GICS Sector come from?
    And what about GICS Sector?



  7. #7
    mountainclimber is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    56
    Quote Originally Posted by orange View Post
    What is this suppose to mean?

    Code:
    [GICS Sector] =  [GICS Sector]
    Where does the value for GICS Sector come from?
    And what about GICS Sector?


    See my post above: #3.

    It comes from the table. It is a field in the table.

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

Similar Threads

  1. Replies: 6
    Last Post: 06-09-2015, 09:51 AM
  2. Aggregate Amounts and group ID together
    By shoro in forum Queries
    Replies: 1
    Last Post: 06-07-2013, 10:59 AM
  3. Replies: 0
    Last Post: 02-25-2013, 04:43 PM
  4. Replies: 5
    Last Post: 11-19-2012, 01:44 PM
  5. Replies: 0
    Last Post: 04-25-2011, 07:58 PM

Tags for this Thread

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