选择TOP x记录数 [英] Select TOP x number of records

查看:108
本文介绍了选择TOP x记录数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个查询,用于计算我们在三个组中拥有的客户百分比。 (主动,非主动,待定)。我们从中得到的表有超过100万条记录。我需要设计一个查询,使用每个组的百分比从表中提取100条记录。防爆。如果活动组占数据库的53%,那么我的100条记录中有53条需要来自活动组。有没有办法将百分比传递到SELECT TOP n记录?还是有其他方法来处理这个问题?

We have a query that calculates the percentage of customers we have in three groups. (Active, Inactive, Pending). The table we get the precentages from has over 1 million records. I need to design a query that will pull 100 records from a table using the percentages of each group. Ex. if the Active Group is 53% of the database then 53 of my 100 records needs to be from the Active group. Is there a way to pass the percentage onto the SELECT TOP n records? or is there another way to handle this?

推荐答案

据我所知,x必须是常量。我想你需要在每次运行之前使用VBA来重写查询定义。
As far as I know, the x has to be a constant. I think you''ll need to use VBA to rewrite the query definition before each run.



我们有一个计算百分比的查询我们分三组的客户。 (主动,非主动,待定)。我们从中得到的表有超过100万条记录。我需要设计一个查询,使用每个组的百分比从表中提取100条记录。防爆。如果活动组占数据库的53%,那么我的100条记录中有53条需要来自活动组。有没有办法将百分比传递到SELECT TOP n记录?还是有另一种方法来处理这个问题?
We have a query that calculates the percentage of customers we have in three groups. (Active, Inactive, Pending). The table we get the precentages from has over 1 million records. I need to design a query that will pull 100 records from a table using the percentages of each group. Ex. if the Active Group is 53% of the database then 53 of my 100 records needs to be from the Active group. Is there a way to pass the percentage onto the SELECT TOP n records? or is there another way to handle this?



幸运的是,Access SQL支持你想要的功能。

Plz阅读访问帮助主题ALL,DISTINCT,DISTINCTROW,TOP Predicates。

Fortunately Access SQL supports the feature you want.
Plz read Access help topic "ALL, DISTINCT, DISTINCTROW, TOP Predicates".



幸运的是Access SQL支持你想要的功能。

Plz阅读访问帮助主题ALL,DISTINCT ,DISTINCTROW,TOP谓词。
Fortunately Access SQL supports the feature you want.
Plz read Access help topic "ALL, DISTINCT, DISTINCTROW, TOP Predicates".



我认为它需要变量,我认为Access不支持。

I think though that it needs to be variable, and I don''t think Access supports that.


这篇关于选择TOP x记录数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆