查询 - 执行计算 [英] Query - Performing Calculations

查看:60
本文介绍了查询 - 执行计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我一直在努力创建数据库的结构,现在我正在尝试创建一些将执行计算的查询。我有一个表,tblAnswers基于追加查询。 tblAnswers包含填写在表格中的预填充问题和相应答案(数字)的列表。


所以tblAnswers有4个字段:AnswerID(autonumber);客户端ID; QuestionNumber;和答案。 ClientID用于将问题/答案与每个客户相关联。


我要做的查询需要计算每个客户的答案。所以我理解将ClientID插入查询中。问题出现在QuestionNumber和Answer字段中。


我将需要对特定问题组进行计算。例如:需要将问题编号201-211加在一起。添加的答案将显示在查询中。我需要做这样的计算大约50-100次。每个都有不同的分组(201-211; 212-214; 215-225?)。


如何设置查询以允许此操作?我是否需要在条件或问题编号中执行此操作?或者我是否需要多次在查询中插入Answers并尝试将每个问题区分为一个分组(如果是,如何?)。在此先感谢。

Hi. I have been working on creating the structure of a DB and now I am trying to create some queries which will perform calculations. I have 1 table, tblAnswers which is based off an append query. tblAnswers contains a list of prepopulated questions and corresponding answers (numeric) which are filled in on the forms.

So tblAnswers has 4 fields: AnswerID (autonumber); ClientID; QuestionNumber; and Answer. ClientID is used to relate the questions/answers to each client.

The query I am going to make needs to calculate answers per client. So I understand to insert the ClientID into the query. My issue arises with the QuestionNumber and Answer fields.

I am going to need to perform calculation on specific question groups. For example: QuestionNumber 201-211 will need to be added together. The added answer would be displayed in the query. I need to do calculations like this about 50-100 times. Each with different groupings (201-211;212-214;215-225?).

How do I set the query up to allow for this? Do I need to do this in the criteria or QuestionNumber? Or do I need to insert Answers multiple times into the query and try to distinguish each one as a grouping (if so, how?). Thanks in advance.

推荐答案

我有一个建议,只需要一个组。为每个问题预定义。这适用于我需要运行的一些查询,但其他查询需要组之间的交互。所以我不确定这会有效。如果有其他人的话,请告诉我。谢谢。
I got a suggestion to simply have a "Group" predefined for each question. This works for some of the queries I will need to run, but others will require interactions between "groups" so I''m not sure this will work. If anyone else has thougths let me know. Thanks.



嗨。我一直在努力创建数据库的结构,现在我正在尝试创建一些将执行计算的查询。我有一个表,tblAnswers基于追加查询。 tblAnswers包含填写在表格中的预填充问题和相应答案(数字)的列表。


所以tblAnswers有4个字段:AnswerID(autonumber);客户端ID; QuestionNumber;和答案。 ClientID用于将问题/答案与每个客户相关联。


我要做的查询需要计算每个客户的答案。所以我理解将ClientID插入查询中。问题出现在QuestionNumber和Answer字段中。


我将需要对特定问题组进行计算。例如:需要将问题编号201-211加在一起。添加的答案将显示在查询中。我需要做这样的计算大约50-100次。每个都有不同的分组(201-211; 212-214; 215-225?)。


如何设置查询以允许此操作?我是否需要在条件或问题编号中执行此操作?或者我是否需要多次在查询中插入Answers并尝试将每个问题区分为一个分组(如果是,如何?)。提前致谢。
Hi. I have been working on creating the structure of a DB and now I am trying to create some queries which will perform calculations. I have 1 table, tblAnswers which is based off an append query. tblAnswers contains a list of prepopulated questions and corresponding answers (numeric) which are filled in on the forms.

So tblAnswers has 4 fields: AnswerID (autonumber); ClientID; QuestionNumber; and Answer. ClientID is used to relate the questions/answers to each client.

The query I am going to make needs to calculate answers per client. So I understand to insert the ClientID into the query. My issue arises with the QuestionNumber and Answer fields.

I am going to need to perform calculation on specific question groups. For example: QuestionNumber 201-211 will need to be added together. The added answer would be displayed in the query. I need to do calculations like this about 50-100 times. Each with different groupings (201-211;212-214;215-225?).

How do I set the query up to allow for this? Do I need to do this in the criteria or QuestionNumber? Or do I need to insert Answers multiple times into the query and try to distinguish each one as a grouping (if so, how?). Thanks in advance.



您可能需要根据一系列分组查询创建一个联合查询,如下面的罗伯特。

You will probably need to create a union query based on a series of grouping queries something like the following Robert.

展开 | 选择 | Wrap | 行号


玛丽,我使用代码遇到了问题:


错误消息:


?您试图运行不包含指定表达式的查询?ClientID?作为聚合函数的一部分。? (错误3122)。


您没有在TRANSFORM语句中输入聚合函数。


与上面相同的代码。我也尝试将ClientID(在选择之后)更改为QuestionNumber,但是会产生相同的错误。 ClientID字段是tblClients中从1开始的anutonumber,并且是tblAnswers中的FK。有什么想法吗?
Mary, I ran into a problem using the code:

Error Message:

?You tried to run a query which does not include the specified expression ?ClientID? as part of an aggregate function.? (Error 3122).

You did not enter an aggregate function in the TRANSFORM statement.

Same code as above. I also tried changing the ClientID (after select) to QuestionNumber but the same error results. The ClientID field is anutonumber starting at 1 in tblClients and is a FK in tblAnswers. Any thoughts?


这篇关于查询 - 执行计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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