Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Multiple AVG Query

Author  Topic 

yanaho
Starting Member

20 Posts

Posted - 2010-02-04 : 12:27:30
Hi, I need help with a query.

2 Columns I am interested in is 'Office' and 'Score' from same table

I would like to get an average score per office in one query.
For example:

Office1AVG Office2 Office3 Office4
98% 80% 75% 90%

Sachin.Nand

2937 Posts

Posted - 2010-02-04 : 12:30:19
select avg(score),office from yourtable group by office

PBUH
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-04 : 12:33:19
how will avg be a %?
Go to Top of Page

yanaho
Starting Member

20 Posts

Posted - 2010-02-04 : 12:57:09
visakh16, sorry it is already a percent.

Thanks Idera, I'm retarded. I pictured the end result differently, but your solution is correct.
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-02-04 : 13:01:14
quote:
Originally posted by yanaho

visakh16, sorry it is already a percent.

Thanks Idera, I'm retarded. I pictured the end result differently, but your solution is correct.




Dont worry it happens sometimes, even simple solution seems tough enough.
But as per ur intial requirement it seems that u need a pivot kind of resultset.

PBUH
Go to Top of Page
   

- Advertisement -