From: | Stuart Rison <stuart(at)ludwig(dot)ucl(dot)ac(dot)uk> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | DISTINCT within aggregates. |
Date: | 1999-03-10 17:01:15 |
Message-ID: | v04003a06b30c53de10b9@[128.40.242.190] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi,
I have PG 6.4 which does not appear to support DISTINCT with aggregates.
Here's an example with the following table:
key|numero
---+-----
1|one
2|two
3|three
4|one
4|four
2|one
(6 rows)
brecard10=> select count(numero) from test;
count
-----
6
(1 row)
brecard10=> select count(numero) from test group by value;
count
-----
1
3
1
1
(4 rows)
brecard10=> select count(distinct numero) from test group by value;
ERROR: parser: Syntax error at or near "distinct"
I want to be able to count how many DISTINCT 'numero' entries there are in
test (i.e 4).
The first statement is a simple count.
The second uses a group which does indeed tell us that there are four
different 'numero's but does not return a unique count.
The last statement is the statement to use (at least according to my SQL
handbook - Bowman et al.) but is not supported by PG 6.4.
Has anybody found a workaround?
cheers,
Stuart.
+-------------------------+--------------------------------------+
| Stuart Rison | Ludwig Institute for Cancer Research |
+-------------------------+ 91 Riding House Street |
| Tel. (0171) 878 4041 | London, W1P 8BT, UNITED KINGDOM. |
| Fax. (0171) 878 4040 | stuart(at)ludwig(dot)ucl(dot)ac(dot)uk |
+-------------------------+--------------------------------------+
From | Date | Subject | |
---|---|---|---|
Next Message | Jason Slagle | 1999-03-10 18:27:20 | Re: [SQL] Performance |
Previous Message | secret | 1999-03-10 15:38:04 | Re: [SQL] How to optimize a query... |