Received: from bjke.com (firewall-user@ganymede.bjke.com [144.210.8.38]) by hub.org (8.9.3/8.9.3) with ESMTP id OAA36377 for ; Fri, 14 May 1999 14:10:36 -0400 (EDT) (envelope-from djackson@cpsgroup.com) Received: by bjke.com; id NAA01051; Fri, 14 May 1999 13:10:34 -0500 (CDT) Received: from unknown(144.210.12.10) by gauntlet.bjke.com via smap (4.1) id xma000867; Fri, 14 May 99 13:10:11 -0500 Received: by cpsmail with Internet Mail Service (5.5.2448.0) id ; Fri, 14 May 1999 13:10:28 -0500 Message-ID: From: "Jackson, DeJuan" To: secret , PG-SQL Subject: RE: [SQL] Oddities with NULL and GROUP BY Date: Fri, 14 May 1999 13:10:25 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2448.0) Content-Type: text/plain The behavior is valid, if you define NULL as meaning undefined. In other words when you define something as NULL you're saying, "I don't know what it is. It could be equal or not." -DEJ > -----Original Message----- > From: secret [SMTP:secret@kearneydev.com] > Sent: Friday, May 14, 1999 11:58 AM > To: PG-SQL > Subject: [SQL] Oddities with NULL and GROUP BY > > Maybe there is something I don't know about how GROUP BY should > work, but if I have a table like: > a,b,c > 1,1,1 > 1,1,2 > 1,1,3 > 1,2,1 > 1,3,1 > > And I say SELECT a,b,sum(c) FROm .. GROUP BY a,b I get > 1,1,6 > 1,2,1 > 1,3,1 > > So whenever a or b changes we get a new summed row, well if I have rows > where a or b are null, this doesn't happen, infact I seem to get all > those rows individually... Like if: > 1,1,1 > 1,1,3 > 1,NULL,10 > 1,NULL,20 > 1,2,3 > > I get: > 1,1,4 > 1,NULL,10 > 1,NULL,20 > 1,2,3 > > Shouldn't I get 1,NULL,30? Ie shouldn't NULL be treated like any other > value? Or is there some bit of information I'm missing? I can set > everything from NULL to 0 if need be, but I'd rather not... > > David Secret > MIS Director > Kearney Development Co., Inc. >