RE: Calculations from query
From: ria (ria_at_discussions.microsoft.com)
Date: Mon, 25 Oct 2004 09:13:08 -0700
group by cust-num and "avg" on OTP.
> I have a query with the following fields:
> Cust-num Order-num Order-line OTP
> AL234 CO343 1 4.5
> AL234 CO343 2 14.6
> AL234 CO764 1 25.3
> AL673 CO903 1 12.3
> AL982 CO356 1 5.77
> AL542 CO215 1 45.4
> AL542 CO215 2 23.5
> I want to have a table that lists each unique Cust-num along with the
> average OTP for that customer based on the previous query.
> Example Table generated:
> Cust-Num Average OTP
> AL234 (4.5+ 14.6+25.3)/3
> AL673 12.3
> AL982 5.77
> AL542 (45.4+23.5)/2
> How do I count # of records in previous query. If I use count or sum
> functions, I have to specify a specific Cust-num, but I want to do it
> for all of them not a specific one.
> Any help is appreciated. Thanks.