Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id CAA68864 for ; Mon, 28 Feb 2000 02:50:39 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id CAA21293; Mon, 28 Feb 2000 02:50:02 -0500 (EST) To: George Dau cc: "'pgsql-sql@postgresql.org'" Subject: Re: [SQL] prob with aggregate and group by - returns multiples In-reply-to: <69D6F577E4ADD311ABE600805FFE80580EBCF9@isaexch.isa.mim.com.au> References: <69D6F577E4ADD311ABE600805FFE80580EBCF9@isaexch.isa.mim.com.au> Comments: In-reply-to George Dau message dated "Mon, 28 Feb 2000 16:22:46 +1000" Date: Mon, 28 Feb 2000 02:50:01 -0500 Message-ID: <21290.951724201@sss.pgh.pa.us> From: Tom Lane George Dau writes: > select count(site), site from hits group by site; > The output contains lines like the following. Note that these are all > consecutive in the output. > 2|xlink.zdnet.com > 2|xlink.zdnet.com > 1|xlink.zdnet.com > 2|xlink.zdnet.com > 2|xlink.zdnet.com > 2|xlink.zdnet.com > 3|xlink.zdnet.com > 2|xlink.zdnet.com > 3|xlink.zdnet.com > 2|xlink.zdnet.com > 1|xlink.zdnet.com > Suspecting that there were differences in each xlink.zdnet.com, I counted > just them: > web=> select count (*) from hits where site='xlink.zdnet.com'; > count > ----- > 22 > (1 row) > So, all 22 xlink.zdnet.com are selected above, but they have not grouped in > the previous one. Any ideas why? Wow, that is bizarre. My first thought was that you had varying numbers of trailing blanks in the "site" values, but your second example seems to disprove that theory. What Postgres version are you running, and on what platform? Can you generate a self-contained example (a script that demonstrates the error from a standing start)? I suspect you may be hitting a platform- specific porting problem, but it's just speculation unless we have a self-contained test case to try on other machines. > On a lesser note: I tried "select * into temp from hits" as per the doco, > but it barfs. Postgres thinks that TEMP is a keyword, so it won't take it as a table name unless you put quotes around it. If we have doco examples that use TEMP as a table name, they need to be changed --- do you recall where you saw that, exactly? regards, tom lane