Re: Counting Distinct Records
От | Thomas F.O'Connell |
---|---|
Тема | Re: Counting Distinct Records |
Дата | |
Msg-id | 6E79C2FE-380B-11D9-95C2-000D93AE0944@sitening.com обсуждение исходный текст |
Ответ на | Re: Counting Distinct Records (Stephan Szabo <sszabo@megazone.bigpanda.com>) |
Ответы |
Re: Counting Distinct Records
|
Список | pgsql-sql |
Is there another way to accomplish what the former is doing, then? For practical reasons, I'd like to come up with something better. For theoretical curiosity, I'd like to know whether there's a way to combine COUNT and DISTINCT that still allows one to reference * rather than naming specific columns without grouping. If I resort to GROUP BY, is there an efficient way of counting all the groups, or would it just be something like: SELECT COUNT ( * ) FROM ( SELECT ... GROUP BY ... ); -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-6320 615-260-0005 On Nov 16, 2004, at 2:03 PM, Stephan Szabo wrote: > On Tue, 16 Nov 2004, Thomas F.O'Connell wrote: > >> I am wondering whether the following two forms of SELECT statements >> are >> logically equivalent: >> >> SELECT COUNT( DISTINCT table.column ) ... >> >> and >> >> SELECT DISTINCT COUNT( * ) ... > > Not in general. > > The former counts how many distinct table.column values there are. The > distinct in the latter would be basically meaningless unless there's a > group by involved. >
В списке pgsql-sql по дате отправления: