Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

Looking to create average rating over daily, weekly, monthly, MTD, quarterly, QTD, yearly, and YTD

$
0
0

I am very new to SQL Server and I am attempting to create span criteria for surveys about our company which will spit out an average depending on the date span given. The detail from the surveys include a survey start date which can be utilized. Here is the sql from the initial table and query building upon it without the date criteria/function:

snippet from surveyTb:

SurveyIDSurveyCallIDSurveyStartSurveyQ1SurveyQ5SurveyQ9
1156/6/13 1:09 PM101010
2196/6/13 2:15 PM101010
4276/7/13 11:20 AM101010
8386/10/13 12:46 PM101010
10446/11/13 1:36 PM101010

etc...

Query without any time criteria:

SELECT 'Company-Avg Overall Service Rating-ExistingPt' AS ID
 , ROUND(AVG(CAST(s.SurveyQ1 AS float)),2) AS DataPoint
FROM [dbo].[SurveyTb] AS s

UNION ALL

SELECT 'Company-Avg Most Recent Transaction Rating-ExistingPt' AS ID
 , ROUND(AVG(CAST(s.SurveyQ5 AS float)),2)  AS DataPoint
FROM [dbo].[SurveyTb] AS s

UNION ALL

SELECT 'Company-Avg Recommendation of Service Rating-ExistingPt' AS ID
 , ROUND(AVG(CAST(s.SurveyQ9 AS float)),2) AS DataPoint
FROM [dbo].[SurveyTb] AS s

RESULT:

IDDataPoint
Company-Avg Overall Service   Rating-ExistingPt9.18
Company-Avg Most Recent Transaction   Rating-ExistingPt9.44
Company-Avg   Recommendation of Service Rating-ExistingPt      9.58

I would like to try and have a daily(yesterday), weekly, monthly, MTD, quarterly, QTD, and yearly & YTD to trend out over time. I appreciate any help I can get!


Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>