From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: lynch@lscorp.com
Cc: pgsql-sql@postgreSQL.org
Subject: Re: count and actual data
Date: Tue, 5 May 1998 10:10:03 +0300
Message-ID: <l03110700b1746951e12c@[147.233.159.109]> (raw)
In-Reply-To: <v02140b36b172882de736@[207.152.64.133]>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: herouth@oumail.openu.ac.il, lynch@lscorp.com
Subject: Re: count and actual data
In-Reply-To: <l03110700b1746951e12c@[147.233.159.109]>
References: <v02140b36b172882de736@[207.152.64.133]> <l03110700b1746951e12c@[147.233.159.109]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox