473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

More efficient way to query fields

I would like to know if it is possible to do a pattern match or better
way to condense my below query in Access 2003.
Basically I need to query the average with all fields in TableOne that
end with _myWord:

Here is what I am using:

select
((avg(abcd_myWord) +
avg(other_myWord) +
avg(here_myWord) +
avg(cal_myWord) +
avg(jersey_myWord) +
avg(flo_myWord) +
avg(jklm_myWord) +
avg(jax_myWord) +
avg(jave_myWord) +
avg(terenv_myWord) +
avg(baewerr_myWord))/11) as avgData
from TableOne

Dec 14 '06 #1
2 1936
Firstly this task would be much easier if the design were normalised to have
another table with fields

desc text (contains "abcd", "other" etc)
myword number

Secondly avg(this) + avg(that) + etc
rarely returns the results that the user is hoping for.
e.g.
this 1 item value 999
that 999 items value 1
do you want to see 1000 as the result?

<te****@hotmail.comwrote in message
news:11**********************@t46g2000cwa.googlegr oups.com...
>I would like to know if it is possible to do a pattern match or better
way to condense my below query in Access 2003.
Basically I need to query the average with all fields in TableOne that
end with _myWord:

Here is what I am using:

select
((avg(abcd_myWord) +
avg(other_myWord) +
avg(here_myWord) +
avg(cal_myWord) +
avg(jersey_myWord) +
avg(flo_myWord) +
avg(jklm_myWord) +
avg(jax_myWord) +
avg(jave_myWord) +
avg(terenv_myWord) +
avg(baewerr_myWord))/11) as avgData
from TableOne


Dec 14 '06 #2
Hi.
Here is what I am using:

select
((avg(abcd_myWord) +
avg(other_myWord) +
avg(here_myWord) +
avg(cal_myWord) +
avg(jersey_myWord) +
avg(flo_myWord) +
avg(jklm_myWord) +
avg(jax_myWord) +
avg(jave_myWord) +
avg(terenv_myWord) +
avg(baewerr_myWord))/11) as avgData
from TableOne
First, adding averages and then dividing by the total number of averages is
seldom going to yield a meaningful value. If the table were normalized, this
query would be much easier and more efficient, but until you normalize it, you
can use a UNION ALL query, then average these values. Try:

SELECT abcd_myWord AS MyWord
FROM TableOne
UNION ALL
SELECT other_myWord AS MyWord
FROM TableOne
.. . .
UNION ALL
SELECT baewerr_myWord AS MyWord
FROM TableOne;

Save the query and name it qryUnionWords. Create another query:

SELECT AVG(MyWord) AS AvgWords
FROM qryUnionWords;

If you're ready to normalize this table, please let us know and we'll help you
develop a query that will fix the table. Keep in mind that any queries, forms,
or reports that rely on the present structure will need to be changed to
accommodate the normalized structure. This is why it's important to design a
database correctly in the first place and to fix problems very early on so that
as little rework as possible is required.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact info.
<te****@hotmail.comwrote in message
news:11**********************@t46g2000cwa.googlegr oups.com...
>I would like to know if it is possible to do a pattern match or better
way to condense my below query in Access 2003.
Basically I need to query the average with all fields in TableOne that
end with _myWord:

Here is what I am using:

select
((avg(abcd_myWord) +
avg(other_myWord) +
avg(here_myWord) +
avg(cal_myWord) +
avg(jersey_myWord) +
avg(flo_myWord) +
avg(jklm_myWord) +
avg(jax_myWord) +
avg(jave_myWord) +
avg(terenv_myWord) +
avg(baewerr_myWord))/11) as avgData
from TableOne

Dec 17 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Shufen | last post by:
Hi, I'm a newbie that just started to learn python, html and etc. I have some questions to ask and hope that someone can help me on. I'm trying to code a python script (with HTML) to get...
6
by: Jason Daly | last post by:
I can't write the sum of a certain colum in a table of a db. <% sql_Sum_Tax="SELECT SUM(vtax) AS sql_Sum_Tax_RS_Var FROM orderstats WHERE vcompletedate BETWEEN "& startDate &" AND "& endDate &...
0
by: R U B'n | last post by:
Hi everyone, I have to make a (case-insensitive) search from a form with only one search string, e.g. "Doe Peters english California", which will search in several fields of my table for each...
6
by: John | last post by:
Just a general question... I'm currently using a combobox that when updated, opens a form with its recordset based on a query using the combo box value as the criteria. I'm I correct in...
4
by: Maur | last post by:
Hi all, I have 2 tables say t_OLD and t_NEW. The new has corrections for audit purposes. They are identical in all respects (i.e. new is a copy of old and then changes are made to t_new) ...
4
by: Bob Alston | last post by:
Some more, rather specific Access performance questions. IN a split front-end & back-end Access/Jet ONLY LAN situation, and with all query criteria fields and join fields indexed: 1. Is is...
11
by: hoopsho | last post by:
Hi Everyone, I am trying to write a program that does a few things very fast and with efficient use of memory... a) I need to parse a space-delimited file that is really large, upwards fo a...
0
by: anonieko | last post by:
This approach I found very efficient and FAST when compared to the rowcount, or Subquery Approaches. This is before the advent of a ranking function from DB such as ROW_NUMBER() in SQL Server...
3
by: Ken Fine | last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets and DataTables should be able to answer fairly easily. The basic question is how I can efficiently match data from one...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.