pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedsum-function
4+ messages / 3 participants
[nested] [flat]
* sum-function
@ 1999-10-22 23:34 Christian Guenther <guenther@laokoon.IN-Berlin.DE>
0 siblings, 1 reply; 4+ messages in thread
From: guenther@laokoon.IN-Berlin.DE @ 1999-10-22 23:34 UTC (permalink / raw)
To: pgsql-sql@hub.org
Hello,
I like to use udmsearch with postgresql, but for searching I need a
funktion like the following. Every time I get an error. Is there
a possibility to make a work around?
udmsearch=> select sum( dict.word = 'mysql') from dict\g
ERROR: Unable to select an aggregate function sum(bool)
What does the ERROR mean.
Thanks for any hint.
Christian
P.S. Sorry about the terrible English.
--
Christian Guenther Kunsthistoriker
Fax: +49 030 4464152 E-mail: cg@kunst-und-kultur.de
Tel: +49 030 4442931 http://kunst-und-kultur.de/
Museen, Kuenstler, Ausstellungen, Kunstprojekte ....
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] sum-function
@ 1999-10-23 04:55 Tom Lane <tgl@sss.pgh.pa.us>
parent: Christian Guenther <guenther@laokoon.IN-Berlin.DE>
0 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 1999-10-23 04:55 UTC (permalink / raw)
To: guenther@laokoon.IN-Berlin.DE; +Cc: pgsql-sql@hub.org
guenther@laokoon.IN-Berlin.DE (Christian Guenther) writes:
> udmsearch=> select sum( dict.word = 'mysql') from dict\g
> ERROR: Unable to select an aggregate function sum(bool)
> What does the ERROR mean.
The '=' operator produces a boolean (true/false) result, but
sum() wants a numeric input. Postgres is a strongly-typed
system, so it doesn't think booleans are interchangeable
with numerics.
It's been suggested several times that Postgres should
provide a standard conversion function that converts
boolean values to 0/1 numeric values, but no one's gotten
around to making one. In the meantime you could get the
result that I think you want with something like
select sum(case when dict.word = 'mysql' then 1 else 0 end) ...
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] sum-function
@ 1999-10-23 16:42 Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 1999-10-23 16:42 UTC (permalink / raw)
To: guenther@laokoon.IN-Berlin.DE; +Cc: pgsql-sql
guenther@laokoon.IN-Berlin.DE (Christian Guenther) writes:
> SELECT (sum(case when dict.word = 'museum' then 1 else 0 end)) as qu,
> dict.url_id FROM dict, url
> WHERE url.rec_id = dict.url_id
> AND url.url LIKE '%%'
> AND dict.word in ('museum')
> GROUP BY dict.url_id
> having qu > 0
> The Problem is qu, I cannot use it for the having.
Neither WHERE nor HAVING pay any attention to column labels; they
work on original attributes. (Only GROUP BY and ORDER BY accept
column labels as substitutes for real expressions.) You'll need
to repeat the sum() expression in HAVING, I'm afraid.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* sum function
@ 2002-10-04 21:01 Dagoberto Torres <francisco99@codetel.net.do>
0 siblings, 0 replies; 4+ messages in thread
From: Dagoberto Torres @ 2002-10-04 21:01 UTC (permalink / raw)
To: pgsql-sql
can somebody tell me how to solve the following problem.?
when I use the sum function I get an error telling me that the provider
returned E_FAIL status. I'm using VB 6 with ADO 2.7 and PSQL 7.2
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2002-10-04 21:01 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-10-22 23:34 sum-function Christian Guenther <guenther@laokoon.IN-Berlin.DE>
1999-10-23 04:55 ` Tom Lane <tgl@sss.pgh.pa.us>
1999-10-23 16:42 Re: [SQL] sum-function Tom Lane <tgl@sss.pgh.pa.us>
2002-10-04 21:01 sum function Dagoberto Torres <francisco99@codetel.net.do>
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