Click here to Skip to main content
15,891,748 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there,
I need a select statement group by, count, average and max. This is what i have so far but i still have error. Can anyone tell me where I went wrong?
SQL
SELECT [Name], count (*) as cnt, MAX([Duration]) as maxDur, format AVG([Duration]) as avgDur FROM tbContractors groupby [Name]


Thanks in advance
Posted
Updated 1-Apr-12 16:15pm
v3
Comments
Pradeep Shukla 1-Apr-12 22:13pm    
What is the error you got?

you are missing the Having cluase
 
Share this answer
 
I've got it by using access query..

SQL
SELECT tbContractors.Name, Avg(tbContractors.Duration) AS AvgOfDuration, Max(tbContractors.Duration) AS MaxOfDuration, Count(tbContractors.Duration) AS CountOfDuration FROM tbContractors GROUP BY tbContractors.Name

Thanks.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900