mysql - SQL idea for a query -


i have kind of table

id-----categoryid-----price  1---------1-----------200  2---------1-----------300  3---------2-----------150  4---------2-----------100 

i need sql query can average of elements category id. results should like:

categoryid----------avg_price  1-------------------250  2-------------------175  

i have not been able think through..

select categoryid, avg(price) table group categoryid 

Comments

Popular posts from this blog

java - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -