Received: from trends.net (root@clio.trends.ca [209.47.148.2]) by hub.org (8.8.8/8.7.5) with ESMTP id KAA11116 for ; Tue, 5 May 1998 10:24:40 -0400 (EDT) Received: from shaked.cc.openu.ac.il (shaked.cc.openu.ac.il [147.233.145.65]) by trends.net (8.8.8/8.8.8) with ESMTP id DAA16128 for ; Tue, 5 May 1998 03:17:25 -0400 (EDT) Received: from [147.233.159.109] (mac-herouth.pc.openu.ac.il [147.233.159.109]) by shaked.cc.openu.ac.il (8.8.5/8.8.5) with ESMTP id KAA17130; Tue, 5 May 1998 10:09:52 +0300 (IDT) X-Sender: herouth@shaked.cc.openu.ac.il Message-Id: In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Tue, 5 May 1998 10:10:03 +0300 To: lynch@lscorp.com (Richard Lynch) From: Herouth Maoz Subject: Re: count and actual data Cc: pgsql-sql@postgreSQL.org At 5:10 +0300 on 4/5/98, Richard Lynch wrote: > Now, I really want the result from the first query, *AND* the count from > the second query. > > select name, count(name) from users; > > would be fine, even if it did give me the count too many times, but it > won't work. > > So. how does one get both the data and the count as results in table format > from a query? Define a function, and select both it and the data... CREATE FUNCTION cnt_usr() RETURNS int4 AS 'SELECT COUNT(name) FROM users' LANGUAGE 'sql'; SELECT name, cnt_usr() FROM users; You do realize, however, that it will do the counting over and over for each line? Herouth