MattSmithProg
Programmer
Hi,
I have a problem trying to return data in a manner that is suitable.
I have a table which records the productivity of people by month. It looks something like this.
UserId Name Site Month Productivity
xxxx1 Fred City 1 0.85
xxxx2 Bob Country 1 1.12
xxxx1 Fred City 2 1.59
xxxx2 Bob Country 2 1.18
.
.
.
.
What I would like is to have the return values after an SQL call to look like this.
Average Productivity/Month
Site 1 2 3 4 5 6 7 8 ..
City 0.85 1.59
Country 1.12 1.18
I have tried
Select Month, Site, Avg(Productivity) From TableName Where Site = 'City' or Site = 'Country' Group By Site, Month Order By Month
I have a feeling that I need to use a Subquery or something similar but I am not sure how to do this as I am still new to SQL.
Could someone please help me.
Thanks
Matt
I have a problem trying to return data in a manner that is suitable.
I have a table which records the productivity of people by month. It looks something like this.
UserId Name Site Month Productivity
xxxx1 Fred City 1 0.85
xxxx2 Bob Country 1 1.12
xxxx1 Fred City 2 1.59
xxxx2 Bob Country 2 1.18
.
.
.
.
What I would like is to have the return values after an SQL call to look like this.
Average Productivity/Month
Site 1 2 3 4 5 6 7 8 ..
City 0.85 1.59
Country 1.12 1.18
I have tried
Select Month, Site, Avg(Productivity) From TableName Where Site = 'City' or Site = 'Country' Group By Site, Month Order By Month
I have a feeling that I need to use a Subquery or something similar but I am not sure how to do this as I am still new to SQL.
Could someone please help me.
Thanks
Matt