热门关键字在 Access 2007 中不起作用
Top Keyword Not Working in Access 2007
SELECT top 3 a.[CustID],a.[CustName],a.[ContactNo],a.[Address],[EmailID] ,
(select count(1) FROM tblCustomer x) as [RecordCount]
FROM tblCustomer a
where a.[CustID] NOT IN (
SELECT TOP 6 m.[CustID]
FROM tblCustomer m
Order by m.[CreatedOn] desc)
order by a.[CreatedOn] desc
我正在尝试从上述查询中获取前 3 个结果,但我得到的远不止于此:
有人可以更正上面的查询吗..
Ms Access 中的 TOP 不仅包括所需的数量,还包括所有匹配的结果。在这种情况下,您选择了日期,因此如果有多个匹配的日期,它们将全部返回。如果您只需要三个记录,除了所需的排序顺序之外,还可以按唯一字段进行排序。例如
... order by a.[CreatedOn] desc, custid
SELECT top 3 a.[CustID],a.[CustName],a.[ContactNo],a.[Address],[EmailID] ,
(select count(1) FROM tblCustomer x) as [RecordCount]
FROM tblCustomer a
where a.[CustID] NOT IN (
SELECT TOP 6 m.[CustID]
FROM tblCustomer m
Order by m.[CreatedOn] desc)
order by a.[CreatedOn] desc
我正在尝试从上述查询中获取前 3 个结果,但我得到的远不止于此:
有人可以更正上面的查询吗..
Ms Access 中的 TOP 不仅包括所需的数量,还包括所有匹配的结果。在这种情况下,您选择了日期,因此如果有多个匹配的日期,它们将全部返回。如果您只需要三个记录,除了所需的排序顺序之外,还可以按唯一字段进行排序。例如
... order by a.[CreatedOn] desc, custid