S31
S31

Reputation: 934

Average Value by Grouping

Trying to get the mean of the Value for each different grouping of TypeID. Something like

SELECT AVG(Value) FROM dbo.TableTest
GROUP BY DISTINCT TypeID 

TableTest

TypeID      PopularityID        CriteriaID      ExposureID     Value
10          20                  5               12             2 
10          20                  4               4              0.90
14          20                  2               10             1.21
15          32                  5               8              0.90
18          20                  3               7              51

Upvotes: 0

Views: 36

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270873

I suspect you want:

SELECT TypeID, AVG(Value)
FROM dbo.TableTest
GROUP BY TypeID ;

Your use of GROUP BY DISTINCT suggests that you need to learn or need a refresher on SQL syntax and the syntax of SELECT queries.

Upvotes: 1

Related Questions