我正在尝试从MS Access中构建的两个单独的sql查询的结果中获取AVERAGE。第一个sql查询提取最大记录:
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;
第二个sql查询提取第二大记录:
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;
这两个查询效果很好,我只需要帮助将这两个查询的结果AVERAGE
合并为一个。感谢。
答案 0 :(得分:0)
联合这些查询并平均记录集
select avg(select field from table1 union select field from table2)
答案 1 :(得分:0)
怎么样
SELECT Avg(FEV1_ACT) FROM
(SELECT Top 2 FEV1_ACT FROM Sheet1 ORDER BY FEV1_ACT DESC)