![]() |
| ||
| Need help in getting Average using SQL Cross Tab 1 Attachment(s) Hi all, I have managed to get my average using cross tabs but only if I have grouped it by their categories. If I remove the GROUP BY clause, the cross tabbing doesn't seem to work. Can anyone help me? I would need to get something like:- Year | Month | Benefits Rating | Facilities Rating Thanks p/s: example is shown as an image below. Attachment 8641 |
| ||
| Re: Need help in getting Average using SQL Cross Tab Make it subquery like below: select [Year], [Month], sum([Benefits Rating]) as [Benefits Rating], sum([Facilities Rating]) as [Facilities Rating] |
| ||
| Re: Need help in getting Average using SQL Cross Tab Hi, I've tried removing the question.category_id from the GROUP BY clause but AVG() doesn't seem to work. It works perfectly fine for SUM() but not AVG(). Below is how the output looks without the question.category_id in the GROUP BY clause. Attachment 8701 |
| ||
| Re: Need help in getting Average using SQL Cross Tab I have managed to find a solution to this problem SELECT DATEPART(year, q.attempted_date) AS Year, DATENAME(MM, q.attempted_date) AS Month, |
| All times are GMT -4. The time now is 12:46 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC