我需要从简单查询中选择特定数量的随机行。该号码以([Formulários]![Survey]![SelectSurveySample])
格式指定。
如果我尝试选择TOP 5,它可以工作,但我想在表格中更改这个数字。
SELECT TOP ([Formulários]![Survey]![SelectSurveySample]) *
FROM [main_table] mt
WHERE (((mt.CPA_Number)=[Formulários]![Survey]![selectCPA_Survey])
AND ((mt.Sample_Household)=False) AND ((mt.Functionality_Survey)=False))
ORDER BY rnd(Int(Now*ID)-Now*Id)
答案 0 :(得分:0)
您是否尝试删除括号 ...
SELECT TOP [Formulários]![Survey]![SelectSurveySample] *
FROM main_table
WHERE (((main_table.CPA_Number)=[Formulários]![Survey]![selectCPA_Survey])
AND ((main_table.Sample_Household)=False)
AND ((main_table.Functionality_Survey)=False))
order by rnd(Int(Now*ID)-Now*Id)
因为这适用于更改为SELECT TOP 5
,并且您在查询中有一个表单变量[Formulários]![Survey]![selectCPA_Survey]
,我看到的唯一区别是括号。