average | | |
hi
I have a query that calculates the average for the year
i group the data by month
i have 2 values for April and may
April = 1908
May = 103
sum = 2011
if i use the avg function it returns 134.1
however if i divide by 12 it returns 167.6
when i check the answer i get 167.6
YTD: SumOfQuantity
in the totals :avg
why does access return 134.1
thanks
kevin | | | | re: average
On May 14, 12:52*am, kevcar40 <kevca...@btinternet.comwrote: Quote:
hi
I have a query that calculates the average *for the year
>
i group the data by month
>
i have 2 values for April and may
April = 1908
May = 103
sum = 2011
if i use the avg function it returns *134.1
>
however if i divide by 12 it returns 167.6
when i check the answer i get 167.6
>
YTD: SumOfQuantity
in the totals *:avg
>
why does access return 134.1
>
thanks
>
kevin
2011 / 134.1 = 15
without seeing the query or all the data, it looks like you've 15
months of data | | | | re: average
On 14 May, 11:33, Roger <lesperan...@natpro.comwrote: Quote:
On May 14, 12:52*am, kevcar40 <kevca...@btinternet.comwrote:
>
>
>
>
> Quote:
hi
I have a query that calculates the average *for the year
> Quote:
i group the data by month
> Quote:
i have 2 values for April and may
April = 1908
May = 103
sum = 2011
if i use the avg function it returns *134.1
> Quote:
however if i divide by 12 it returns 167.6
when i check the answer i get 167.6
> Quote:
YTD: SumOfQuantity
in the totals *:avg
> Quote:
why does access return 134.1
> > >
2011 / 134.1 = 15
without seeing the query or all the data, it looks like you've 15
months of data- Hide quoted text -
>
- Show quoted text -
thanks for reply
i dont think i am averaging 15 months
i have place the query code below
TRANSFORM Sum(Quantity_Query.SumOfQuantity) AS SumOfQuantity
SELECT Quantity_Query.years, Avg(Quantity_Query.SumOfQuantity) AS YTD
FROM Quantity_Query
WHERE (((Quantity_Query.years)='2008'))
GROUP BY Quantity_Query.years
PIVOT Quantity_Query.months In
('January','February','March','April','May','June' ,'July','August','September','October','November', 'December');
thanks
kevin | | | | re: average
On May 14, 4:57*am, kevcar40 <kevca...@btinternet.comwrote: Quote:
On 14 May, 11:33, Roger <lesperan...@natpro.comwrote:
>
>
>
>
> Quote:
On May 14, 12:52*am, kevcar40 <kevca...@btinternet.comwrote:
> Quote: Quote:
hi
I have a query that calculates the average *for the year
> Quote: Quote:
i group the data by month
> Quote: Quote:
i have 2 values for April and may
April = 1908
May = 103
sum = 2011
if i use the avg function it returns *134.1
> Quote: Quote:
however if i divide by 12 it returns 167.6
when i check the answer i get 167.6
> Quote: Quote:
YTD: SumOfQuantity
in the totals *:avg
> Quote: Quote:
why does access return 134.1
> > > Quote:
2011 / 134.1 = 15
without seeing the query or all the data, it looks like you've 15
months of data- Hide quoted text -
> Quote:
- Show quoted text -
>
thanks for reply
>
i dont think i am averaging 15 months
>
i have place the query code below
>
TRANSFORM Sum(Quantity_Query.SumOfQuantity) AS SumOfQuantity
SELECT Quantity_Query.years, Avg(Quantity_Query.SumOfQuantity) AS YTD
FROM Quantity_Query
WHERE (((Quantity_Query.years)='2008'))
GROUP BY Quantity_Query.years
PIVOT Quantity_Query.months In
('January','February','March','April','May','June' ,'July','August','Septemb*er','October','November' ,'December');
>
thanks
kevin- Hide quoted text -
>
- Show quoted text -
so if you just run this query
SELECT Quantity_Query.years, Quantity_Query.months,
Quantity_Query.SumOfQuantity FROM Quantity_Query
WHERE (((Quantity_Query.years)='2008'))
you get just 2 values, may and april ?
if that's the case the avg should be 2011/2 = 1005 | | | | re: average
On 14 May, 16:11, Roger <lesperan...@natpro.comwrote: Quote:
On May 14, 4:57*am, kevcar40 <kevca...@btinternet.comwrote:
>
>
>
>
> Quote:
On 14 May, 11:33, Roger <lesperan...@natpro.comwrote:
> Quote: Quote:
On May 14, 12:52*am, kevcar40 <kevca...@btinternet.comwrote:
> Quote: Quote:
hi
I have a query that calculates the average *for the year
> Quote: Quote:
i group the data by month
> Quote: Quote:
i have 2 values for April and may
April = 1908
May = 103
sum = 2011
if i use the avg function it returns *134.1
> Quote: Quote:
however if i divide by 12 it returns 167.6
when i check the answer i get 167.6
> Quote: Quote:
YTD: SumOfQuantity
in the totals *:avg
> Quote: Quote:
why does access return 134.1
> > > Quote: Quote:
2011 / 134.1 = 15
without seeing the query or all the data, it looks like you've 15
months of data- Hide quoted text -
> Quote: Quote:
- Show quoted text -
> > Quote:
i dont think i am averaging 15 months
> Quote:
i have place the query code below
> Quote:
TRANSFORM Sum(Quantity_Query.SumOfQuantity) AS SumOfQuantity
SELECT Quantity_Query.years, Avg(Quantity_Query.SumOfQuantity) AS YTD
FROM Quantity_Query
WHERE (((Quantity_Query.years)='2008'))
GROUP BY Quantity_Query.years
PIVOT Quantity_Query.months In
('January','February','March','April','May','June' ,'July','August','Septemb**er','October','November ','December');
> Quote:
thanks
kevin- Hide quoted text -
> Quote:
- Show quoted text -
>
so if you just run this query
SELECT Quantity_Query.years, Quantity_Query.months,
Quantity_Query.SumOfQuantity FROM Quantity_Query
WHERE (((Quantity_Query.years)='2008'))
>
you get just 2 values, may and april ?
if that's the case the avg should be 2011/2 = 1005- Hide quoted text -
>
- Show quoted text -
i agree
but for some reason when i run the crosstab query it returns 134.1 | | | | re: average
On May 15, 3:18*am, kevcar40 <kevca...@btinternet.comwrote: Quote:
On 14 May, 16:11, Roger <lesperan...@natpro.comwrote:
>
>
>
>
> Quote:
On May 14, 4:57*am, kevcar40 <kevca...@btinternet.comwrote:
> Quote: Quote:
On 14 May, 11:33, Roger <lesperan...@natpro.comwrote:
> Quote: Quote:
On May 14, 12:52*am, kevcar40 <kevca...@btinternet.comwrote:
> Quote: Quote:
hi
I have a query that calculates the average *for the year
> Quote: Quote:
i group the data by month
> Quote: Quote:
i have 2 values for April and may
April = 1908
May = 103
sum = 2011
if i use the avg function it returns *134.1
> Quote: Quote:
however if i divide by 12 it returns 167.6
when i check the answer i get 167.6
> Quote: Quote:
YTD: SumOfQuantity
in the totals *:avg
> Quote: Quote:
why does access return 134.1
> > > Quote: Quote:
2011 / 134.1 = 15
without seeing the query or all the data, it looks like you've 15
months of data- Hide quoted text -
> Quote: Quote:
- Show quoted text -
> > Quote: Quote:
i dont think i am averaging 15 months
> Quote: Quote:
i have place the query code below
> Quote: Quote:
TRANSFORM Sum(Quantity_Query.SumOfQuantity) AS SumOfQuantity
SELECT Quantity_Query.years, Avg(Quantity_Query.SumOfQuantity) AS YTD
FROM Quantity_Query
WHERE (((Quantity_Query.years)='2008'))
GROUP BY Quantity_Query.years
PIVOT Quantity_Query.months In
('January','February','March','April','May','June' ,'July','August','Septemb***er','October','Novembe r','December');
> Quote: Quote:
thanks
kevin- Hide quoted text -
> Quote: Quote:
- Show quoted text -
> Quote:
so if you just run this query
SELECT Quantity_Query.years, Quantity_Query.months,
Quantity_Query.SumOfQuantity FROM Quantity_Query
WHERE (((Quantity_Query.years)='2008'))
> Quote:
you get just 2 values, may and april ?
if that's the case the avg should be 2011/2 = 1005- Hide quoted text -
> Quote:
- Show quoted text -
>
i agree
but for some reason when i run the crosstab query *it returns 134.1- Hide quoted text -
>
- Show quoted text -
and if you don't use a crosstab, just a regular query
SELECT Quantity_Query.years, Avg(Quantity_Query.SumOfQuantity) AS YTD
FROM Quantity_Query
WHERE (((Quantity_Query.years)='2008'))
GROUP BY Quantity_Query.years
what do you get ? | | | | re: average
On 15 May, 11:11, Roger <lesperan...@natpro.comwrote: Quote:
On May 15, 3:18*am, kevcar40 <kevca...@btinternet.comwrote:
>
>
>
>
> Quote:
On 14 May, 16:11, Roger <lesperan...@natpro.comwrote:
> Quote: Quote:
On May 14, 4:57*am, kevcar40 <kevca...@btinternet.comwrote:
> Quote: Quote:
On 14 May, 11:33, Roger <lesperan...@natpro.comwrote:
> Quote: Quote:
On May 14, 12:52*am, kevcar40 <kevca...@btinternet.comwrote:
> Quote: Quote:
hi
I have a query that calculates the average *for the year
> Quote: Quote:
i group the data by month
> Quote: Quote:
i have 2 values for April and may
April = 1908
May = 103
sum = 2011
if i use the avg function it returns *134.1
> Quote: Quote:
however if i divide by 12 it returns 167.6
when i check the answer i get 167.6
> Quote: Quote:
YTD: SumOfQuantity
in the totals *:avg
> Quote: Quote:
why does access return 134.1
> > > Quote: Quote:
2011 / 134.1 = 15
without seeing the query or all the data, it looks like you've 15
months of data- Hide quoted text -
> Quote: Quote:
- Show quoted text -
> > Quote: Quote:
i dont think i am averaging 15 months
> Quote: Quote:
i have place the query code below
> Quote: Quote:
TRANSFORM Sum(Quantity_Query.SumOfQuantity) AS SumOfQuantity
SELECT Quantity_Query.years, Avg(Quantity_Query.SumOfQuantity) AS YTD
FROM Quantity_Query
WHERE (((Quantity_Query.years)='2008'))
GROUP BY Quantity_Query.years
PIVOT Quantity_Query.months In
('January','February','March','April','May','June' ,'July','August','Septemb****er','October','Novemb er','December');
> Quote: Quote:
thanks
kevin- Hide quoted text -
> Quote: Quote:
- Show quoted text -
> Quote: Quote:
so if you just run this query
SELECT Quantity_Query.years, Quantity_Query.months,
Quantity_Query.SumOfQuantity FROM Quantity_Query
WHERE (((Quantity_Query.years)='2008'))
> Quote: Quote:
you get just 2 values, may and april ?
if that's the case the avg should be 2011/2 = 1005- Hide quoted text-
> Quote: Quote:
- Show quoted text -
> Quote:
i agree
but for some reason when i run the crosstab query *it returns 134.1- Hide quoted text -
> Quote:
- Show quoted text -
>
and if you don't use a crosstab, just a regular query
SELECT Quantity_Query.years, Avg(Quantity_Query.SumOfQuantity) AS YTD
FROM Quantity_Query
WHERE (((Quantity_Query.years)='2008'))
GROUP BY Quantity_Query.years
>
what do you get ?- Hide quoted text -
>
- Show quoted text -
hi
i get the same answer 134.1 | | | | re: average
On May 16, 3:40*am, kevcar40 <kevca...@btinternet.comwrote: Quote:
On 15 May, 11:11, Roger <lesperan...@natpro.comwrote:
>
>
>
>
> Quote:
On May 15, 3:18*am, kevcar40 <kevca...@btinternet.comwrote:
> Quote: Quote:
On 14 May, 16:11, Roger <lesperan...@natpro.comwrote:
> Quote: Quote:
On May 14, 4:57*am, kevcar40 <kevca...@btinternet.comwrote:
> Quote: Quote:
On 14 May, 11:33, Roger <lesperan...@natpro.comwrote:
> Quote: Quote:
On May 14, 12:52*am, kevcar40 <kevca...@btinternet.comwrote:
> Quote: Quote:
hi
I have a query that calculates the average *for the year
> Quote: Quote:
i group the data by month
> Quote: Quote:
i have 2 values for April and may
April = 1908
May = 103
sum = 2011
if i use the avg function it returns *134.1
> Quote: Quote:
however if i divide by 12 it returns 167.6
when i check the answer i get 167.6
> Quote: Quote:
YTD: SumOfQuantity
in the totals *:avg
> Quote: Quote:
why does access return 134.1
> > > Quote: Quote:
2011 / 134.1 = 15
without seeing the query or all the data, it looks like you've 15
months of data- Hide quoted text -
> Quote: Quote:
- Show quoted text -
> > Quote: Quote:
i dont think i am averaging 15 months
> Quote: Quote:
i have place the query code below
> Quote: Quote:
TRANSFORM Sum(Quantity_Query.SumOfQuantity) AS SumOfQuantity
SELECT Quantity_Query.years, Avg(Quantity_Query.SumOfQuantity) AS YTD
FROM Quantity_Query
WHERE (((Quantity_Query.years)='2008'))
GROUP BY Quantity_Query.years
PIVOT Quantity_Query.months In
('January','February','March','April','May','June' ,'July','August','Septemb*****er','October','Novem ber','December');
> Quote: Quote:
thanks
kevin- Hide quoted text -
> Quote: Quote:
- Show quoted text -
> Quote: Quote:
so if you just run this query
SELECT Quantity_Query.years, Quantity_Query.months,
Quantity_Query.SumOfQuantity FROM Quantity_Query
WHERE (((Quantity_Query.years)='2008'))
> Quote: Quote:
you get just 2 values, may and april ?
if that's the case the avg should be 2011/2 = 1005- Hide quoted text -
> Quote: Quote:
- Show quoted text -
> Quote: Quote:
i agree
but for some reason when i run the crosstab query *it returns 134.1-Hide quoted text -
> Quote: Quote:
- Show quoted text -
> Quote:
and if you don't use a crosstab, just a regular query
SELECT Quantity_Query.years, Avg(Quantity_Query.SumOfQuantity) AS YTD
FROM Quantity_Query
WHERE (((Quantity_Query.years)='2008'))
GROUP BY Quantity_Query.years
> Quote:
what do you get ?- Hide quoted text -
> Quote:
- Show quoted text -
>
hi
i get the same answer *134.1- Hide quoted text -
>
- Show quoted text -
don't know what's happening
I created a table with columns year,month,qty
filled it with 2008,Apr,1908
2008,May, 103
ran this query
TRANSFORM Sum(tblMonth.qty) AS SumOfqty
SELECT tblMonth.year, Avg(tblMonth.qty) AS AvgOfqty
FROM tblMonth
WHERE (((tblMonth.year)=2008))
GROUP BY tblMonth.year
PIVOT tblMonth.month;
and got
year avg apr may
2008 105.5 1908 103
which is correct
maybe your db is corrupt ? and an index is corrupt ? |  | Similar Microsoft Access / VBA bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,327 network members.
|