I am having some issues with the standard deviation function (stddev_samp in MonetDB specifically). I tried the following queries without success:
select industry, avg(marketcap) as industryavg, stddev_samp(marketcap) as industrysd from cumulativeview group by industry
select stddev_samp(marketcap) as industrysd from cumulativeview group by industry
Each gives me a very weird exception and it seems the stddev function does not work on a group by subset, however using the avg function alone seems to work just fine on a group by subset as in the following query:
select industry, avg(marketcap) as industryavg from cumulativeview group by industry
And the standard deviation function works just fine when i use a where clause instead of a group by:
select stddev_samp(marketcap) as industrysd from cumulativeview where industry='Diversified Investments'
Is there an alternate way to write a query that would give me the average and standard deviation for each industry all at once rather than having to go through and write a seperate query for each industry? I am very confused as to why the average function works with group by and stddev does not...