davefwelch
David
- Local time
- Today, 11:08
- Joined
- Jan 4, 2005
- Messages
- 47
you tried to exe query that did not include specified expr "" as part of aggregate Fn
Here is the SQL for the query I'm trying to run:
The error message is:
You tried to execute a query that does not include the specified expression 'NAICS' as part of an aggregate function.
I'm making a lot of work for myself here to save some later. Actually, I want to make this easy to minimize the chance for a mistake later. Sample is a table with nearly 2000 businesses surveyed, as well as characteristics such as industry, size, and location. Survey is a table with over 100 fields from a survey of those businesses about the fringe benefits they offer to employees. Many of the fields are Yes/No, hence the "-1" test for a true answer in Q-3F. I've figured out how to calculate percentages of employees (Q-1 is the number of full-time employees) that are offered each benefit for every business who responded. Now, I want to transfer that to queries that will break the percentages down based on characteristics of the companies where the employees work. For example, I want to figure out the percent of employees offered paid holidays at businesses in the health care industry (In the SQL above, NAICS represents the industry). Or, the percent of employees offered paid holidays at businesses with over 250 employees. Or, the third and final characteristic, I want the percent of employees offered paid holidays at businesses in a certain county.
If possible, I would rather not have to create separate domains by creating a select query for each industry, size, and area.
Here is the SQL for the query I'm trying to run:
Code:
SELECT Sum(IIf(Survey![Q-3F]="-1",Survey![Q-1],0))/Sum(Survey![Q-1]) AS expr1, Sample.NAICS
FROM Survey INNER JOIN Sample ON Survey.SampleID = Sample.SampleID;
The error message is:
You tried to execute a query that does not include the specified expression 'NAICS' as part of an aggregate function.
I'm making a lot of work for myself here to save some later. Actually, I want to make this easy to minimize the chance for a mistake later. Sample is a table with nearly 2000 businesses surveyed, as well as characteristics such as industry, size, and location. Survey is a table with over 100 fields from a survey of those businesses about the fringe benefits they offer to employees. Many of the fields are Yes/No, hence the "-1" test for a true answer in Q-3F. I've figured out how to calculate percentages of employees (Q-1 is the number of full-time employees) that are offered each benefit for every business who responded. Now, I want to transfer that to queries that will break the percentages down based on characteristics of the companies where the employees work. For example, I want to figure out the percent of employees offered paid holidays at businesses in the health care industry (In the SQL above, NAICS represents the industry). Or, the percent of employees offered paid holidays at businesses with over 250 employees. Or, the third and final characteristic, I want the percent of employees offered paid holidays at businesses in a certain county.
If possible, I would rather not have to create separate domains by creating a select query for each industry, size, and area.