sql字符串获取最小值最小值的最大值

时间:2019-01-24 18:18:29

标签: sql ms-access

我有两个表,我希望有一个sql查询来获取表的最大值的并集的字段的最小值。

Set tmpRS = CurrentDb.OpenRecordset(" SELECT MIN(s.TorqueMax) FROM ( " & _
    " (SELECT MAX(ds.TorqueMax) FROM tblUIOpTorqueRangeDS ds)" & _
    " UNION " & _
    " (SELECT MAX(cv.TorqueMax) FROM tblUIOpTorqueRangeCV cv )) as s")

1 个答案:

答案 0 :(得分:1)

您可以执行以下操作:

SELECT MIN(s.TorqueMax)
FROM (SELECT MAX(ds.TorqueMax) as TorqueMax
      FROM tblUIOpTorqueRangeDS ds
      UNION 
      SELECT MAX(cv.TorqueMax) as TorqueMax
      FROM tblUIOpTorqueRangeCV cv
     ) as s;