473,473 Members | 1,807 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

need help with sql and group by

Hello all

I need an sql statement that will do this:

this is my database

name testscore occurance
carol 33 1
carol 99 2
gene 39 1
paul 32 1
carol 45 3
gene 100 2
gene 11 3
gene 44 4

I want the result to be:
name avg(testscore) occurance
carol 59 1
carol 59 2
carol 59 3
gene 48.5 1
gene 48.5 2
gene 48.5 3
gene 48.5 4
paul 32 1
I want to average the scores for each name, but then list each instance of
the name next to the average.
I know I can do this in a few steps with a group by on the average for each
name, and then link to original database

but is there an easier way to do this using one line of sql?

Thanks for your time
Danny



Nov 13 '05 #1
1 1109
SELECT [Name], DAvg("testscore", "TableName", "[Name]='" & [Name] & "'")
AS AvgTestScore, Occurance
FROM TableName;

--

Ken Snell
<MS ACCESS MVP>

"Danny" <da********@hotmail.com> wrote in message
news:2C*********************@news4.srv.hcvlny.cv.n et...
Hello all

I need an sql statement that will do this:

this is my database

name testscore occurance
carol 33 1
carol 99 2
gene 39 1
paul 32 1
carol 45 3
gene 100 2
gene 11 3
gene 44 4

I want the result to be:
name avg(testscore) occurance
carol 59 1
carol 59 2
carol 59 3
gene 48.5 1
gene 48.5 2
gene 48.5 3
gene 48.5 4
paul 32 1
I want to average the scores for each name, but then list each instance of
the name next to the average.
I know I can do this in a few steps with a group by on the average for each name, and then link to original database

but is there an easier way to do this using one line of sql?

Thanks for your time
Danny


Nov 13 '05 #2

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

Similar topics

9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
7
by: Shyguy | last post by:
I have an option group with about 30 options. I would like to have the Option Labels get their text from a table. Is this possible, and if so how? Also, is it possible to embad a font into a...
7
by: ChadDiesel | last post by:
Hello everyone, I'm having a problem with Access that I need some help with. The short version is, I want to print a list of parts and part quantities that belong to a certain part group---One...
10
by: Tom | last post by:
I am looking for some ideas for how to design the layout of the form for data entry and to display the data for the following situation: There are many sales associates. A sales associate can work...
0
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional...
9
by: Brian Hampson | last post by:
I am trying to determine all the groups which the current user has permissions to add a member. Here's my code: foreach (System.DirectoryServices.SearchResult ADSearchres in...
0
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need ...
3
by: sunbeam | last post by:
Short Description of the Project: we developed a e-learning system for our students. each student has a unique username/password to view the modules he/she should view and nothing more. since we...
0
by: Chuck36963 | last post by:
Hi all, I've been working on a listing problem and I can't figure out how to work it out. I have looked far and wide on the web to find answers, but I'd like other peoples input on my project in...
2
by: speavey | last post by:
When I run this query, I get an ORDER BY error "Incorrect syntax near the keyword 'ORDER'. I've bolded it below. If I take the ORDER by out then it works correctly, but I need the ORDER BY...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.