SUM() and GROUP BY

From: "D'Arcy" "J(dot)M(dot)" Cain <darcy(at)druid(dot)net>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: SUM() and GROUP BY
Date: 1999-01-08 17:40:23
Message-ID: m0zyftX-0000fKC@druid.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Does this seem right?

druid=> SELECT COUNT(*) FROM acctrans;
count
-----
0
(1 row)

druid=> SELECT client_id, SUM(tramount) FROM acctrans GROUP BY client_id;
client_id|sum
---------+---
|
(1 row)

If there are no rows in the table then shouldn't the result be no rows
when GROUP BY is used? Further, What about this?

druid=> SELECT SUM(tramount) FROM acctrans;
sum
---

(1 row)

Shouldn't that be 0.00?

What will the NUMERIC or DECIMAL types do in these situations? It
looks like INTEGER has the same behaviour as MONEY (which tramount is.)

--
D'Arcy J.M. Cain <darcy(at){druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 424 2871 (DoD#0082) (eNTP) | what's for dinner.

Browse pgsql-hackers by date

  From Date Subject
Next Message The Hermit Hacker 1999-01-08 17:54:12 Re: [HACKERS] 6.4 lateness and CIDR
Previous Message Paul A Vixie 1999-01-08 17:19:32 6.4 lateness and CIDR