Results 1 to 2 of 2
  1. #1
    springboardjg is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2011
    Location
    Milton Keynes
    Posts
    10

    Multiple SQL Statements

    Hi

    I am new to Access and have a basic understanding of SQL.

    I have a query that returns a data set that I then want to apply an Average function to. I know the SQL statement to perform the Average function (it involves GROUP BY).

    Basically I know how to do these two steps individually, but can someone give me some guidance on how to apply the second Average query to the dataset returned by the first query.

    Here are the two queries if it helps.

    First Query:


    Code:
    SELECT [Site Serial], [Previous Year], [Current Month], [Average Grouping]
    FROM [Sites and Weekly Averages]
    WHERE ([Previous Year] IS NOT NULL) AND ([Current Month] IS NOT NULL);
    Second Query:
    Code:
    SELECT [Average Grouping], AVG ([Previous Month]), AVG ([Current Month])
    FROM [Sites and Weekly Averages]
    GROUP BY [Average Grouping];

    Many thanks

    James

  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,521
    How about

    SELECT ...
    FROM FirstQueryName
    GROUP BY ...
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. If statements
    By swagger18 in forum Programming
    Replies: 6
    Last Post: 01-28-2011, 08:13 PM
  2. Multiple IIF statements
    By KevinMCB in forum Queries
    Replies: 4
    Last Post: 12-03-2010, 01:35 PM
  3. Replies: 3
    Last Post: 10-13-2010, 03:35 PM
  4. SQL statements from VBA
    By John Southern in forum Programming
    Replies: 12
    Last Post: 05-16-2010, 01:07 PM
  5. IIF Statements
    By JDA2005 in forum Queries
    Replies: 8
    Last Post: 07-07-2009, 04:24 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