Get the AVG of two SQL Access Queries

Posted by reggiereg on Stack Overflow See other posts from Stack Overflow or by reggiereg
Published on 2010-04-27T12:55:58Z Indexed on 2010/04/27 13:03 UTC
Read the original article Hit count: 281

Filed under:
|
|
|
|

Hi, I'm trying to get the AVERAGE from the results of two separate sql queries built in MS Access. The first sql query pulls the largest record:

SELECT DISTINCTROW Sheet1.Tx_Date, Sheet1.LName, Sheet1.Patient_Name, Sheet1.MRN, 
  Max(Sheet1.) AS [Max Of FEV1_ACT], 
  Max(Sheet1.FEF_25_75_ACT) AS [Max Of FEF_25_75_ACT]
FROM Sheet1
GROUP BY Sheet1.Tx_Date, Sheet1.LName, Sheet1.Patient_Name, Sheet1.MRN;

The second sql query pulls the second largest record:

SELECT Sheet1.MRN, Sheet1.Patient_Name, Sheet1.Lname, 
  Max(Sheet1.FEV1_ACT) AS 2ndLrgOfFEV1_ACT, 
  Max(Sheet1.FEF_25_75_ACT) AS 2ndLrgOfFEF_25_75_ACT
FROM Sheet1
WHERE (((Sheet1.FEV1_ACT)<(SELECT MAX( FEV1_ACT )
                 FROM Sheet1 )))
GROUP BY Sheet1.MRN, Sheet1.Patient_Name, Sheet1.Lname;

These two queries work great, I just need some help on pulling the AVERAGE of the results of these two queries into one. Thanks.

© Stack Overflow or respective owner

Related posts about avg

Related posts about ms-access