Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 8069C632386 for ; Fri, 26 Mar 2010 03:24:04 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 56702-04 for ; Fri, 26 Mar 2010 06:23:50 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.17.10]) by mail.postgresql.org (Postfix) with ESMTP id E347063161C for ; Fri, 26 Mar 2010 03:23:52 -0300 (ADT) Received: from webserv.wug.de ([194.25.154.138]) by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis) id 0M7o3Q-1Nhtkk3mD2-00vCvP; Fri, 26 Mar 2010 07:23:51 +0100 Received: from kretschmer by webserv.wug.de with local (Exim 3.36 #1) id 1Nv2xS-0001uN-00 for pgsql-sql@postgresql.org; Fri, 26 Mar 2010 07:23:50 +0100 Date: Fri, 26 Mar 2010 07:23:50 +0100 From: "A. Kretschmer" To: pgsql-sql@postgresql.org Subject: Re: SQL syntax rowcount value as an extra column in the result set Message-ID: <20100326062350.GA6817@a-kretschmer.de> References: <594D625E4784AD4EA9D423E292BE6725489FD1@mlbe2k10.cs.myharris.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-OS: Debian/GNU Linux - weil ich es mir Wert bin! User-Agent: Mutt/1.5.9i X-Provags-ID: V01U2FsdGVkX1+k/LXgjgOl4vyIHcJysRdCc+NvJ+6bsdJyAV7 nGSMqloOZB3jrv4/yew0R/+9hM16264KTzPG5M9UPLF9/m3ovv h43eZmfdwLLI/1bOJYwVA== X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.966 tagged_above=-10 required=5 tests=AWL=0.633, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201003/199 X-Sequence-Number: 33906 In response to Jayadevan M : > Hi, > I don't think so. > Oracle - > SQL> select count(*) over () as ROWCOUNT , first_name from people; > > ROWCOUNT FIRST_NAME > ---------- > --------------------------------------------------------------------- > ------------------------------- > 6 Mary > 6 Mary > 6 John > 6 John > 6 John > 6 Jacob > > 6 rows selected. > > PostgreSQL > postgres=# select count(*) over () as ROWCOUNT , first_name from people; > ERROR: syntax error at or near "over" > LINE 1: select count(*) over () as ROWCOUNT , first_name from people... It works, but you should use a recent version: test=*# select count(1) over (), i from foo; count | i -------+---- 8 | 1 8 | 2 8 | 3 8 | 6 8 | 7 8 | 9 8 | 13 8 | 14 (8 rows) test=*# select version(); version -------------------------------------------------------------------------------------------------------- PostgreSQL 8.4.2 on x86_64-pc-linux-gnu, compiled by GCC gcc-4.3.real (Debian 4.3.2-1.1) 4.3.2, 64-bit (1 row) test=*# Regards, Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431 2EB0 389D 1DC2 3172 0C99