If I wanted to use the avg value for Value in your statement, where would I put the statement saying AVG(Value) AS avg_value?
do you mean this?
SELECT SUM(Tot)/SUM(Cnt)
FROM
(
SELECT Computer,SUM(Value) AS Tot,COUNT(*) AS Cnt,
MAX(CASE WHEN Value > 80 THEN 2 WHEN Value BETWEEN 70 AND 80 THEN 1 ELSE 0 END) AS Flag
FROM Table
GROUP BY Computer
)t
WHERE Flag = 1
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c
No comments:
Post a Comment