Re: [SQL] PgSQL 6.5.1 and Group BY pb

From: Giampiero Raschetti <Giampiero(dot)Raschetti(at)popso(dot)it>
To: Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il>
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] PgSQL 6.5.1 and Group BY pb
Date: 1999-08-25 14:12:24
Message-ID: 37C3F9C8.BB2E42DF@popso.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Herouth Maoz wrote:
>
> At 14:08 +0300 on 25/08/1999, Giampiero Raschetti wrote:
>
> > ...............................
>
> I think you have a misunderstanding about the purpose of group by statements.
>
> In fact, the above seems to indicate that you are not well aware of what
> joins are, or at least you don't know that you have to restrict them to
> make sense of your data. You really have to add WHERE g.id = u.id.
>

OK. That's true. I'm not well aware of SQL in general but if you
try out that secuence into postgres 6.4.2 you will see that it works.
So I understand that probably it was not standard. Well.

Let's take a look at this same problem without any join involved
and if possible let me know how to obtain my target:

xaxa=> \d comuni
Table = comuni
+----------------------------------+----------------------------------+-------+
| Field | Type |
Length|
+----------------------------------+----------------------------------+-------+
| produtt | varchar()
| 40 |
| unital | varchar()
| 40 |
| comune | varchar()
| 40 |
| login | varchar()
| 8 |
+----------------------------------+----------------------------------+-------+

xaxa=> select * from comuni;
produtt| unital|comune |login
-------+---------------+------------+-----
xxx |199900200000100|POGGIRIDENTI|user1
yyy |199900200000100|POGGIRIDENTI|user2
yyy |199900200000100|ARDENNO |USER3
yyy |199900200000100|BORMIO |user2
(4 rows)

xaxa=> select * from comuni group by login;
ERROR: Illegal use of aggregates or non-group column in target list
xaxa=>

This works too on Postgres 6.4.2 so how can I obtain a list of
unique users from this table on 6.5.1 ?

Many Thanks

--
Best Regards
----------------------------
Giampiero Raschetti
Sistemi Innovativi
Banca Popolare di Sondrio
----------------------------

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Heiko Wilms 1999-08-25 14:42:50 harddisk crash
Previous Message Tom Lane 1999-08-25 14:07:43 Re: [SQL] PgSQL 6.5.1 and Group BY pb