Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Query question

Status
Not open for further replies.

toryee

Technical User
Aug 14, 2003
23
US
I have trouble understanding the following two fields in an Access query and the differnces between them.
Any explanation is appreciated.



1) emp: sum(IIf([employee].[age] = "45", [employee].[salary], 0))
this is a column with 'Expression' under 'Total'


2) Expr1: IIF([employee].[age] = "45", [employee].[salary], 0))
This is a column with 'Group by' under 'Total'

 
toryee,

The two fields are using the same criteria but the result of the fields will be different based on what the total line is doing.

For the first field will give me the sum for all employees who are 45 years of age. In the second field you will have the salaries for those employee who are 45.

HTH,

Steve
 
If these were the only two fields in the query, then you'd get a row for each unique salary for employees aged 45 and then the sum of the salaries for employees aged 45 with that salary. The sum field would just be the salary multiplied by the number of employees with that exact salary.

Code:
  emp   expr1
 40000   80000   (assuming 2 employees at 40K)
 30000   30000   (assuming 1 employee at 30K)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top