SELECT TOP 1 First(a.control_no) AS 最小记录
FROM [SELECT Query2.control_no, Count(Query2.control_no) AS 计数 FROM Query2 GROUP BY Query2.control_no]. AS a
GROUP BY a.计数
ORDER BY a.计数;
从本题来看,以下查询更为合理:
SELECT TOP 1 a.Control_No
FROM Control_No AS a LEFT JOIN tblSaleReport AS b ON a.Control_No=b.Control_No
WHERE (((b.MAWB_NBR) Is Null));
原理一样,在多几个也没关系,呵呵。
SELECT TOP 1 Control_No.Control_No
FROM (Control_No LEFT JOIN salereport2 ON Control_No.Control_No=salereport2.Control_No) LEFT JOIN SaleReport1 ON Control_No.Control_No=SaleReport1.Control_No
WHERE (((salereport2.MAWB_NBR) Is Null) AND ((SaleReport1.MAWB_NBR) Is Null));