Results 1 to 2 of 2
  1. #1
    SummertimeClothes is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2012
    Posts
    1

    Finding Max of two nested aggregate functions in SQL

    I have an MS Access 2007 Database with the following tables and attributes:

    • Characters: Name
    • Planets: Name
    • TimeTable: Planet's Name, Character's Name, Movie

    Time Table denotes if a character has visited a planet, there may be multiple entries for one planet.
    The query I'm trying to get is this one:
    For each movie, which characters visited the highest number of planets?

    This is my attempt:

    Quote:
    SELECT T.Movie, T.[Character's Name], Count(T.[Planet's Name]) AS planets
    FROM TimeTable T
    GROUP BY T.Movie, T.[Character's Name]
    HAVING Count(T.[Planet's Name]) >= ALL (SELECT Count(T2.[Planet's Name])
    FROM TimeTable T2 WHERE T.Movie = T2.Movie);

    It gives me an empty result though. What is wrong with my query?

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Can you post a small data sample, and what your expected results should look like?

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

Similar Threads

  1. aggregate functions
    By gsrikanth in forum Access
    Replies: 3
    Last Post: 07-10-2012, 03:56 PM
  2. Replies: 5
    Last Post: 02-23-2012, 05:22 PM
  3. nested functions not working in 2010?
    By Gdm in forum Queries
    Replies: 2
    Last Post: 08-02-2010, 08:02 AM
  4. Concatenation, nested IIF functions
    By krymer in forum Queries
    Replies: 2
    Last Post: 10-20-2008, 07:27 AM
  5. Replies: 0
    Last Post: 06-07-2007, 02:33 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