Solved

Syntax for: Average of  Field values

Posted on 2009-07-08
2
194 Views
Last Modified: 2012-05-07
Hi Experts

I have a client database, which holds records of client data including their purchase rates (ie transactions per year). Now I'd like to determine the average Purchase rate for the whole group of clients.

Can a sql be written to calculate the average??? ( or do i need to set up a loop, add each purchase rate and the divide by the nr of clients)

eg (VB6, Access 2003 database)
Client_Id     Client_PurchaseRate

sql = "Select distinct Client_ID from CLIENT_DETAILS "
?Sql .......determine average rate  ????

Set dsClients = CURDB.OpenRecordset (sql, dbOpenDynaset)

0
Comment
Question by:peterdarazs
2 Comments
 
LVL 17

Accepted Solution

by:
pssandhu earned 500 total points
ID: 24810946
Select ClientID, AVG(PurchaseRate) AvgRate
From   Client_Details
Group by CLientID
This is in MS Sql Server syntax.
P.
0
 

Author Closing Comment

by:peterdarazs
ID: 31601433
Ok, thanks , that 'll help a lot....
P
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now