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

Home Posts Topics Members FAQ

How to get the average of a count field in a SQL query

I have this query which gives a count of how many times a specific client_name shows up in a table and creates of count of that and calls it "Hits"....

SELECT client_name, COUNT(1) AS Hits FROM All_Data GROUP BY client_name

I would like to take this one step further and just return the average "Hits" for this one query as one result. Can I do this all on one line? If so, could someone help me do this? Thanks, Chris
Nov 4 '10 #1
2 2273
ck9663
2,878 Expert 2GB
There's an AVG() function in SQL Server.

Good Luck!!!

~~ CK
Nov 4 '10 #2
I think I figured it out:

select sum(hits)/count(*) as AverageHits
from (SELECT client_name, COUNT(1) AS Hits FROM All_Data GROUP BY client_name) AS Hitquery
Nov 4 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Simon Bailey | last post by:
I currently have a query calculating the gap in days between two dates. The fields being "DateLookedAt" and "DateResolved" plus the calculated field "TimeTaken". I am looking to add another...
4
by: bob hicky | last post by:
I have two tables (RadiationOncologists and EvaluationEntry) and forms for each of the two. My problem is that I have a text box in the RadiationOncologists form that is called Number. This field...
4
by: alltechsolutions.net | last post by:
Been at this for two days now... I have a customer database with various fields, two of which are: ContactID (an autonumber field) & ReferralID (long Integer) When a customer refers someone...
1
by: aps786 | last post by:
Hi, There is a table where I store ipaddress and user who logged in from that IP. I have a query to findout all ipaddresses, from where diff users had made request. stat ------------ ip...
1
by: Vikas | last post by:
Hi all, I am working on a document control database where I have a table "tblControl" containing two columns "DocID" and "SchIssueDate". "DocID" is the key field with text format while...
5
by: Genalube | last post by:
I am trying to count the number of owners that show up in a query (conveyQuery). The query will produce a column OwnName that will contain names like John Smith, Mike Jones, Frank Vaugn. Each of...
4
by: Proogeren | last post by:
Hello I have the following query SELECT COUNT(ur.resourceId) AS times_downloaded FROM Resource as r, user_resource as ur WHERE r.resourceId = ur.resourceId Group BY ur.resourceId
2
by: magmike | last post by:
I need to display the count of records there are for each unique value in a table. In this case, it is by date - how many calls are scheduled for each date. Each call is a record in a table. So the...
2
by: tomric | last post by:
I have a query that sorts data from a table based on a build type. Each build type has several designs, and each design has several bars associated with it. For each bar there is 42 to 64 different...
10
Jerry Maiapu
by: Jerry Maiapu | last post by:
In my tabular (format) report I would like to count only the fields with “AOT” in a column Overtime. How do I do that in the report? I know this is possible in query but for certain reasons I want to...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
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...

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.