Table字段获取数组变量的唯一值

Table字段获取数组变量的唯一值

本文介绍了从Acces Table字段获取数组变量的唯一值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我正在努力寻找合适的代码来执行以下任务:

I am struggling to find the right code to perform the following task:

我有一个字段" ProductNumber"在访问表(这是一个基于时间戳的记录表)中。我从数百个文本文件中获取此表的数据。因此,Access表格中的数据是动态的。

I have a field "ProductNumber" in an Access Table (which is a timestamp based record table). I get data to this table from hundreds of text files. So data in Access table is dynamic.

" ProductNumber"字段包含整数产品数字(最少有10000条记录)。

"ProductNumber" field contains Integer product numbers (there are 10000 records as a minimum).

但是,它可能只是整个表中的一个或几个独特的产品(这意味着可以说2000产品#2的记录,6000个产品记录#8和产品#1的其余2000条记录。

However, it might be only one or few unique products in the whole table (it means that there are lets say 2000 records of product #2, 6000 records of product #8 and the rest 2000 records of product #1).

我想快速制作一个VBA函数,在没有循环遍历整个字段的情况下输出带有3个数字的数组:2,8,1。

I would like to make a VBA function that quickly and without looping through the entire field would output array with 3 numbers in this case: 2, 8, 1.

拥有一个具有唯一数字的数组我可以使用SQL构建一个查询,该查询将该特定数组作为数据过滤的标准。

Having an array with unique numbers I could then use SQL to built a query that would have that particular array as s criteria for data filtering.

有什么建议吗?

推荐答案

SELECT DISTINCT ProductNumber FROM NameOfTheTable

SELECT DISTINCT ProductNumber FROM NameOfTheTable

将返回唯一的产品编号。您可以在其他查​​询中将其用作子查询,或者可以在此SQL上打开记录集(DAO或ADODB)并以任何方式使用它。

will return the unique product numbers. You can use this as a subquery in other queries, or you can open a recordset (DAO or ADODB) on this SQL and use it any way you want.


这篇关于从Acces Table字段获取数组变量的唯一值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 19:13