Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d6Tz2-0006OT-Fo for pgsql-admin@arkaria.postgresql.org; Fri, 05 May 2017 03:32:45 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d6Tz1-0007PD-Qd for pgsql-admin@arkaria.postgresql.org; Fri, 05 May 2017 03:32:43 +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 1d6TxF-0004G5-S5 for pgsql-admin@postgresql.org; Fri, 05 May 2017 03:30:53 +0000 Received: from m12-14.163.com ([220.181.12.14]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d6Tx8-0001ot-Rt for pgsql-admin@postgresql.org; Fri, 05 May 2017 03:30:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Message-ID:Date:MIME-Version; bh=nMEPr rHQmwb8Nv/IwXDL51ULRoVsqmtkpCm2dncza5Q=; b=BT3IOUrEI2865P7vMSMud DyiSmbYSU67aSpv1ghUPILlYXIMjuVaxfbFzA16zqaMkkdARPrnSjJ26JKiukIt6 x+xOcWttRU298tsRfq1Z7XJthwK522ysZrxhwNn9kj0vXpu99aq3m7im+waJYTYc rDQgaUMeG/Yy0uYMso1/f4= Received: from winstondeMacBook-Pro.local (unknown [1.180.215.84]) by smtp10 (Coremail) with SMTP id DsCowADHY5DU8QtZ6o2dDQ--.24535S2; Fri, 05 May 2017 11:30:29 +0800 (CST) To: pgsql-admin@postgresql.org From: winston cheung Subject: windown function count Unexpected results Message-ID: Date: Fri, 5 May 2017 11:31:21 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID: DsCowADHY5DU8QtZ6o2dDQ--.24535S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Ar13Wry7Kry3CFWxtFy3twb_yoW8Xr18pr yaqF4xJFWkKryfJryrJrWxCFy5trs8Aa47tFWftrykJwn8Zr1IkFWDtFWrtay5WryDWFyU Zw1UXF1Ika15AF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07b62-5UUUUU= X-Originating-IP: [1.180.215.84] X-CM-SenderInfo: pzlq23prqbuxphxqwqqrwthudrp/1tbiMBXOmlWBagYfuwAAst X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org hello When I used the count in the window function, I found that the results were not true. In the table I use department_id as a partition condition, I think when department_id = 30, the calculation of salary <3000 should be 4, when department_id = 50,the calculation of salary < 3000 should be 20, why the value of each line are different? Thanks a lot! postgres@160.40:5410/testdb=# select department_id as dep_id, concat(first_name, ' ', last_name) as employee_name, salary, count(*) over w from employees where salary<3000 window w as (partition by department_id order by salary desc); dep_id | employee_name | salary | count --------+-------------------+---------+------- 30 | Shelli Baida | 2900.00 | 1 30 | Sigal Tobias | 2800.00 | 2 30 | Guy Himuro | 2600.00 | 3 30 | Karen Colmenares | 2500.00 | 4 50 | Michael Rogers | 2900.00 | 2 50 | Timothy Gates | 2900.00 | 2 50 | Vance Jones | 2800.00 | 5 50 | Mozhe Atkinson | 2800.00 | 5 50 | Girard Geoni | 2800.00 | 5 50 | John Seo | 2700.00 | 7 50 | Irene Mikkilineni | 2700.00 | 7 50 | Douglas Grant | 2600.00 | 10 50 | Randall Matos | 2600.00 | 10 50 | Donald OConnell | 2600.00 | 10 50 | Joshua Patel | 2500.00 | 15 50 | Peter Vargas | 2500.00 | 15 50 | Martha Sullivan | 2500.00 | 15 50 | James Marlow | 2500.00 | 15 50 | Randall Perkins | 2500.00 | 15 50 | James Landry | 2400.00 | 17 50 | Ki Gee | 2400.00 | 17 50 | Hazel Philtanker | 2200.00 | 19 50 | Steven Markle | 2200.00 | 19 50 | TJ Olson | 2100.00 | 20 (24 rows) winston , regards -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin