I have two tables as follow:
the tables are linked to each other using the SRGT key, I want to calculate the average values for each RESPONDENT_SRGT.
Explanation:
the screenshot below represents the inner join of the two tables:
The needed Results:
I just want the average as a mesure so I can calculate the count of RESPONDENT that have an average greater than or equal to 4, for this example, I will get 2 RESPONDENTS.
I was Able to achieve the desired results in SQL server with the bellow query:
(SELECT COUNT(*) FROM
(SELECT AVG(Cast(DIM.VALUE as Float)) AS AVR
FROM [dbo].[FACT_TABLE] FACT
INNER JOIN [dbo].[DIM_ANSWER_TABLE] DIM
ON FACT.ANSWER_SRGT = DIM.ANSWER_SRGT
GROUP BY FACT.RESPONDENT_SRGT) QRB
WHERE QRB.AVR >= 4 )


