Reputation: 7
Given a table, I need to compute the interquartile range for 25% and 75% quartile--it should be just one output the difference.
Note: 'gini' is just a column in my table rdata; I am not going to input my data here as the data is very long but I just need to figure out how to output the difference through percentile_disc/cont.
select percentile_disc(0.75)-percentile_disc(0.25) within group (order by gini) from rdata;
output error:
LINE 1: select percentile_disc(0.75)-percentile_disc(0.25) within gr...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts..
I tried to cast percentile_disc::numeric but that gives me an error too.
Upvotes: 0
Views: 884
Reputation: 12494
The problem is that the within group
has to be specified for each percentile_disc()
select percentile_disc(0.75) within group (order by gini) -
percentile_disc(0.25) within group (order by gini)
from rdata;
Upvotes: 1