Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eKMaj-00033u-Nt for pgsql-general@arkaria.postgresql.org; Thu, 30 Nov 2017 11:01:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eKMaj-0004Ua-94 for pgsql-general@arkaria.postgresql.org; Thu, 30 Nov 2017 11:01:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eKMaj-0004TU-1p for pgsql-general@lists.postgresql.org; Thu, 30 Nov 2017 11:01:17 +0000 Received: from smtp10.hushmail.com ([65.39.178.143]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eKMaT-0005M5-34 for pgsql-general@postgresql.org; Thu, 30 Nov 2017 11:01:15 +0000 Received: from smtp10.hushmail.com (localhost [127.0.0.1]) by smtp10.hushmail.com (Postfix) with SMTP id 373E6C08A3 for ; Thu, 30 Nov 2017 11:00:57 +0000 (UTC) Received: from smtp.hushmail.com (w2.hushmail.com [65.39.178.46]) by smtp10.hushmail.com (Postfix) with ESMTP; Thu, 30 Nov 2017 11:00:54 +0000 (UTC) Subject: Re: Searching for big differences between values To: Durumdara , pgsql-general@postgresql.org References: From: Chris Mair Message-ID: <932d868d47b18e1793b20f3d2f42ab58@smtp.hushmail.com> Date: Thu, 30 Nov 2017 12:00:41 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > 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.