avg() in a small group

avg , sql , nigger United States
  • 8 years ago

    How do you use AVG in sql to manage grouped output? For example: Given a SQL Table “Employee”

    Name Salary City

    John Doe 15000 Seattle Jane Doe 30000 Redmond Tim Wayne 25000 Seattle

    Write a SQL query that would return the average salary per city in the format shown below:

    City Salary

    Seattle 20000 Redmond 30000

    Select City, AVG(Salary) from Employee where ... I don't know the rest

    Where city == city or something like that?

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” - Antoine de Saint Exupéry