【发布时间】:2012-11-23 10:33:29
【问题描述】:
我正在使用 MS Access 2003。
我有这种结构的记录表:
ID, Origin, Destination, Attr1, Attr2, Attr3, ... AttrX
for example:
1, 1000, 1100, 20, M, 5 ...
2, 1000, 1105, 30, F, 5 ...
3, 1001, 1000, 15, M, 10 ...
...
我也有分组了起点和终点代码的表格
Code, Country, Continent
1000, Albania, Europe
1001, Belgium, Europe
...
1100, China, Asia
1105, Japan, Asia
...
我需要的是获得 2 个表,这些表将根据与我指定的属性相关的条件对记录进行计数,但按以下条件分组:
1. 始发大陆和目的地大陆
2. 始发地和目的地国
例如:
案例 1。
Origin, Destination, Total, Females, Males, Older than 20, Younger than 20, ...
Europe, China, 300, 100, 200, 120, 180 ...
Europe, Japan, 150, 100, 50, ...
...
案例 2。
Origin, Destination, Total, Females, Males, Older than 20, Younger than 20, ...
Europe, Asia, 1500, 700, 800 ...
Asia, Europe, 1200, ...
...
是否可以这样做,以便我可以轻松地添加更多列/标准?
【问题讨论】:
-
在类似的情况下,我使用了一个允许用户选择条件并在 VBA 中构建查询的表单。我不确定你会得到一个令人满意的纯 sql 解决方案。