From: | Chris Mair <chris(at)1006(dot)org> |
---|---|
To: | Durumdara <durumdara(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Searching for big differences between values |
Date: | 2017-11-30 11:00:41 |
Message-ID: | 932d868d47b18e1793b20f3d2f42ab58@smtp.hushmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> I need to search for big differences between values.
[...]
Hi,
from an SQL point of view this is not difficult, but you need to
carefully define a criteria for the outliers.
For example, to find values that are more than a standard deviation
away from the mean, do something like this:
chris=# select * from val;
x
-------
20
21
21.5
30
28
46392
46393
40
(8 rows)
chris=# select * from val where x > (select avg(x) + stddev(x) from val) or x < (select avg(x) - stddev(x) from val);
x
-------
46392
46393
(2 rows)
Try with n*stddev(x) for n = 2, 3, 4, 5, ... to see
if you can get to your outliers...
Bye,
Chris.
From | Date | Subject | |
---|---|---|---|
Next Message | Rory Campbell-Lange | 2017-11-30 11:36:22 | Re: Searching for big differences between values |
Previous Message | Peter J. Holzer | 2017-11-30 10:22:09 | Re: large numbers of inserts out of memory strategy |