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)); 作者: yimu 时间: 2010-8-4 16:44
谢谢楼上的高人,能大概解释下意思不?因为最近工作中可能还需要用到类似语句,我刚刚用help看了,但还是很不明白
谢谢作者: todaynew 时间: 2010-8-4 17:18 本帖最后由 todaynew 于 2010-8-4 17:19 编辑
原理一样,在多几个也没关系,呵呵。
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));