Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XcslF-0003Pj-Sd for pgsql-bugs@arkaria.postgresql.org; Sat, 11 Oct 2014 09:14:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XcslF-00023R-Ci for pgsql-bugs@arkaria.postgresql.org; Sat, 11 Oct 2014 09:14:49 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XcslD-00023H-DM for pgsql-bugs@postgresql.org; Sat, 11 Oct 2014 09:14:47 +0000 Received: from mail-lb0-f174.google.com ([209.85.217.174]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1Xcsl5-0000SE-GU for pgsql-bugs@postgresql.org; Sat, 11 Oct 2014 09:14:45 +0000 Received: by mail-lb0-f174.google.com with SMTP id p9so4270526lbv.5 for ; Sat, 11 Oct 2014 02:14:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=ncecyakXlBGQcDKTNrDKuwDtcLGCxFPgmIXN6S6DE+Y=; b=Iy1/8122AAINimXKrSRCaFotmJhbYBgEZES5Vzvoyvtv+EF65/3n6QlgQNBUFG37hr 6PiIgPhO9pXdD0Z3BT5Btuf27G5nKWmYn+yNWA3+0XNbDcqiEGavCP4eI55LCHTgLZMG bps6hZczpHezCxAErTcy+k20Hfh7ry1BiEwA/BVzJmclC82OznRcBmAg3hh682fYLdJl IU3zsN42Zxdur8EMIYs9CrI/atIB1iFd9xBZEMAgxQSdcBm+cn9kN/aGYpfOs6QI60D0 +FOGIPHy1g9a1ZarOLmRy9lDJjIweqjzZTKriTIHT3PCtAVYcMC0eR15v4hYBSLsceDV gR6Q== X-Gm-Message-State: ALoCoQkrV2Toxo49kw/IUlt7XlLDmmAd10gp0I8WzFVV2z9nGPBezmBFVXtphWHhabh+6a2nIV3e X-Received: by 10.112.243.43 with SMTP id wv11mr1284046lbc.95.1413018876556; Sat, 11 Oct 2014 02:14:36 -0700 (PDT) Received: from dalli.local (c-5eeaaa35-74736162.cust.telenor.se. [94.234.170.53]) by mx.google.com with ESMTPSA id qs2sm1619135lbb.28.2014.10.11.02.14.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 11 Oct 2014 02:14:35 -0700 (PDT) Message-ID: <5438F4FB.9060108@joh.to> Date: Sat, 11 Oct 2014 11:14:35 +0200 From: Marko Tiikkaja User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: jai.soni@elbizsystems.com, pgsql-bugs@postgresql.org Subject: Re: BUG #11642: Aggregate Functions like min, max return one row in case of no rows in table References: <20141011073109.7983.80503@wrigleys.postgresql.org> In-Reply-To: <20141011073109.7983.80503@wrigleys.postgresql.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 10/11/14, 9:31 AM, jai.soni@elbizsystems.com wrote: > Aggregate Functions like min, max return one row in case of no rows in table > it should return 0 rows as it return while using normal field in select > query According to whom? This behaviour is well defined in the SQL standard and documented for example here: http://www.postgresql.org/docs/9.3/static/sql-select.html#SQL-GROUPBY "Aggregate functions, if any are used, are computed across all rows making up each group, producing a separate value for each group (whereas without GROUP BY, an aggregate produces a single value computed across all the selected rows)." .marko -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs