View Single Post
  #4  
Old May 20th, 2010, 01:11 PM posted to microsoft.public.access.gettingstarted
John Spencer
external usenet poster
 
Posts: 7,815
Default Queries to reduce a set of data pairs

SELECT [O].AreaElem
, [O].Joint
, [O].GlobalX
, Avg([GlobalY]) AS AvglY
, Avg([M_sd]) AS AvgM
FROM [Objects And Elements - Joints Consulta] as O
GROUP BY AreaElem, Joint, GlobalX

The query looks good so obviously I don't understand what you are trying to
accomplish. For instance, what is a "node"?

The best I can see is to remove Joint and GlobalX from the query if you want
the averages for each areaElem.

SELECT [O].AreaElem
, Avg([GlobalY]) AS AvglY
, Avg([M_sd]) AS AvgM
FROM [Objects And Elements - Joints Consulta] as O
GROUP BY AreaElem

It might help if you took the same data and gave us what you want returned
from the sample data. Your original posting said you wanted the following
fields returned. So what do you expect to see based on your sample data?

AreaElem Joint GlobalX Avg(GlobalY) Avg(M_sd)

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Rui Maciel wrote:
On May 19, 9:54 pm, John Spencer wrote:

snip

I've tried to follow your suggestion but I wasn't able to make my
query return a condensed version of the original table. Unfortunately
it still returns 4 joints per node. Could you please take a look at
my SQL to try to see what I'm doing wrong?

The SQL is as follows:
sql
SELECT [Objects And Elements - Joints Consulta].AreaElem, [Objects And
Elements - Joints Consulta].Joint, [Objects And Elements - Joints
Consulta].GlobalX, Avg([GlobalY]) AS AvglY, Avg([M_sd]) AS AvgM
FROM [Objects And Elements - Joints Consulta]
GROUP BY AreaElem, Joint, GlobalX
/sql


Thanks for the help,
Rui Maciel