Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQxb8-0003Ap-9O for pgsql-general@arkaria.postgresql.org; Mon, 18 Dec 2017 15:44:58 +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 1eQxb7-0007ea-SZ for pgsql-general@arkaria.postgresql.org; Mon, 18 Dec 2017 15:44:57 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eQxb7-0007eQ-FA for pgsql-general@lists.postgresql.org; Mon, 18 Dec 2017 15:44:57 +0000 Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eQxb3-0001r0-O5 for pgsql-general@postgresql.org; Mon, 18 Dec 2017 15:44:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20170201; h=In-Reply-To:Content-Type:MIME-Version:References:Reply-To:Message-ID:Subject:Cc:To:Sender:From:Date; bh=HaOrAoHpOEtLNEC3JLt7JcQv2eN58A03GT5zaDaXeGo=; b=TrHx+u6Hq+DQa/xJUj1kCMa4pyCIr3rf1KFd+Vw4ssf9V3OTsmXn78oD1p/CxF1xv/cuV3IMOzEAdqVf+/Syc/r2zqm5Jp/M+SvR+ohv1HbsHBeE68rv0A9Kbjiu6tuYUS9f5pA/w38Yn5PmoCwokj2ltyi8F2wbI0nIGcpLnxQ=; Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by depesz.com with esmtpa (Exim 4.84_2) (envelope-from ) id 1eQxb0-0005qI-1W; Mon, 18 Dec 2017 16:44:50 +0100 Date: Mon, 18 Dec 2017 16:44:49 +0100 From: hubert depesz lubaczewski Sender: depesz@depesz.com To: Nick Dro Cc: pgsql-general@postgresql.org Subject: Re: PostgreSQL needs percentage function Message-ID: <20171218154449.GA19797@depesz.com> Reply-To: depesz@depesz.com References: <^75EF6A639D2C0E83BEC677FB95E668672BBAB816@walla.co.il> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <^75EF6A639D2C0E83BEC677FB95E668672BBAB816@walla.co.il> User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Dec 18, 2017 at 02:23:38PM +0200, Nick Dro wrote: > Hi, > Why PostgreSQL doesn't have build-in function to calculate percentage? > somthing like percent(number,% > for example: > select percent(100,1) will calculate 1% of 100 = 1 > select percent(25,20) will calculate 20% of 25 = 5 What is the problem with using normal multiplication for this? depesz