E
excelCPA
I have a query that pulls in data from payroll and sales tables.
Results are similar to the following:
Payroll_No L_Name Sale_No Sale_Amt
12345 Smith 2434 100
12345 Smith 3434 200
12345 Smith 3654 50
23456 Jones 7870 50
23456 Jones 7987 200
45678 Phillips 2223 100
45678 Phillips 9898 50
45678 Phillips 9896 300
45678 Phillips 7878 200
45678 Phillips 8989 400
The SQL is:
SELECT tblPerson.Payroll_No, tblPerson.L_Name, tblSale.Sale_No,
tblSale.Sale_Amt
FROM tblSale INNER JOIN tblPerson ON tblSale.Payroll_No = tblPerson.
Payroll_No
I need to make the query summarize the data per payroll number by
count, sum, and average similar to a Pivot Table. The results for the
data above would look like this:
Payroll_No L_Name Count_Sale_No Sum_Sale_Amt Avg_Sale_Amt
12345 Smith 3
350 116.67
23456 Jones 2
250 175
45678 Phillips 5
1050 2100
How can this be accomplished? Thanks.
Results are similar to the following:
Payroll_No L_Name Sale_No Sale_Amt
12345 Smith 2434 100
12345 Smith 3434 200
12345 Smith 3654 50
23456 Jones 7870 50
23456 Jones 7987 200
45678 Phillips 2223 100
45678 Phillips 9898 50
45678 Phillips 9896 300
45678 Phillips 7878 200
45678 Phillips 8989 400
The SQL is:
SELECT tblPerson.Payroll_No, tblPerson.L_Name, tblSale.Sale_No,
tblSale.Sale_Amt
FROM tblSale INNER JOIN tblPerson ON tblSale.Payroll_No = tblPerson.
Payroll_No
I need to make the query summarize the data per payroll number by
count, sum, and average similar to a Pivot Table. The results for the
data above would look like this:
Payroll_No L_Name Count_Sale_No Sum_Sale_Amt Avg_Sale_Amt
12345 Smith 3
350 116.67
23456 Jones 2
250 175
45678 Phillips 5
1050 2100
How can this be accomplished? Thanks.