I have a table like:
id B C
a 0.5 10.1
b 0.6 2.3
c 0.9 2.1
d 15.2 8.2
And I would like to calculate a quantity like: “the standard deviation of the C for which B is below the average”.
And I don’t know how to do that.
select ssdev_pop(C) from (select B, C from table where B < avg(B) );
Doesn’t work, and I don’t know how to access to avg(B) in one go (I know I could calculate it and plug it into a second query but I want to avoid that).
Can somebody help?
try this one,
Demo: http://www.sqlfiddle.com/#!2/9d570/8