From: Alexey Pikunov <apikunov@falt.deep.ru>
To: pgsql-sql@postgreSQL.org
Subject: [SQL] Troubles whith using aggregat inside function.
Date: Fri, 19 Feb 1999 17:36:42 +0300
Message-ID: <7733.990219@falt.deep.ru> (raw)
Hello !
I have troble creating function:
/************************ Begin *****************************/
mgetty=> create function get_stat(datetime, datetime) returns timespan as'
mgetty'> select
mgetty'> sum(tt1.stop - tt1.start)+($2 - $1)+(tt3.stop - $1)+($2 - tt4.start)
mgetty'> from ttyd0 tt1,ttyd0 tt2,ttyd0 tt3,ttyd0 tt4
mgetty'> where tt1.start > $1 and tt1.stop < $2
mgetty'> and tt2.start < $1 and tt2.stop > $2
mgetty'> and tt3.start < $1 and tt3.stop < $2 and tt3.stop > $1
mgetty'> and tt4.start > $1 and tt4.stop > $2 and tt4.start < $2;
mgetty'> ' language 'sql';
ERROR: parser: illegal use of aggregates or non-group column in target list
mgetty=> \d ttyd0
Table = ttyd0
+----------------------------------+----------------------------------+-------+
| Field | Type | Length|
+----------------------------------+----------------------------------+-------+
| start | datetime not null | 8 |
| stop | datetime not null | 8 |
| boundrate | int4 | 4 |
+----------------------------------+----------------------------------+-------+
Index: ttyd0_start_key
/************************* End ******************************/
In addition, when I try to get sum() for empty dataset Server cancels
client (psql).
Is there any solution for this problems?
(PostgreeSQL v6.4.2)
Best regards,
Alexey mailto:apikunov@falt.deep.ru
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: apikunov@falt.deep.ru
Subject: Re: [SQL] Troubles whith using aggregat inside function.
In-Reply-To: <7733.990219@falt.deep.ru>
References: <7733.990219@falt.deep.ru>
* 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