Re: [SQL] count(distinct)

2009-02-06 Thread Richard Huxton
Zdravko Balorda wrote: > this is probably an old issue but I'm not all that experienced. > > I wonder if an index can be accessed rather directly, as to speed up > a query like "select count(distinct())", by simply calculating the > number of branches (leaves) an index has. Or at least to skip sor

[SQL] count(distinct)

2009-02-06 Thread Zdravko Balorda
Hi, this is probably an old issue but I'm not all that experienced. I wonder if an index can be accessed rather directly, as to speed up a query like "select count(distinct())", by simply calculating the number of branches (leaves) an index has. Or at least to skip sorting. Best regards, Zdr

Re: [SQL] COUNT DISTINCT?

2002-07-30 Thread Josh Berkus
Stephan, > Would that be the same as: > select count(distinct skip_date) from weekend_list > where ... Yeah, that would be what I was looking for. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 4: Don't '

Re: [SQL] COUNT DISTINCT?

2002-07-30 Thread Stephan Szabo
On Tue, 30 Jul 2002, Josh Berkus wrote: > Folks, > > Anybody know a keen shortcut for the following: > > SELECT count(skip_date) > FROM (SELECT DISTINCT skip_date FROM weekend_list > WHERE ... ...) days_to_skip; > > That's a double aggregate, and is bound to be dog-slow. Would tha

Re: [SQL] count( distinct x )

2000-11-27 Thread Tom Lane
Anthony <[EMAIL PROTECTED]> writes: > I think it's time to get Mr. Sysadmin to upgrade to v7 ;) That's a good idea on many grounds, not only this one ;-) However, if you really need a 6.5.* solution, you could do SELECT DISTINCT foo INTO TEMP TABLE mytemp FROM ... SELECT COUNT(*

Re: [SQL] count( distinct x )

2000-11-27 Thread Anthony
Kenn Thompson wrote: > Ok- messy, but it works > > CREATE VIEW testview AS > select distinct area from areapostcode where postcode like 'BS1%'; > > SELECT COUNT(*) FROM testview; > > kenn > > >>> Anthony <[EMAIL PROTECTED]> 11/27/00 01:07PM >>> > Kenn Thompson wrote: > > > What about > > > >

Re: [SQL] count( distinct x )

2000-11-27 Thread Anthony
Najm Hashmi wrote: > Anthony wrote: > > > Michael Fork wrote: > > > > > I think you want > > > > > > SELECT count(distinct(area)) FROM areapostcode WHERE postcode LIKE 'BS1%' > > > > > > > psql still not happy :( > > > > SELECT count(distinct(area)) FROM areapostcode WHERE postcode LIKE 'BS1%'; >

Re: [SQL] count( distinct x )

2000-11-27 Thread Anthony
Tom Lane wrote: > Anthony <[EMAIL PROTECTED]> writes: > > select count( distinct area ) from areapostcode where postcode like > > 'BS1%' > > the above statement fails with > > ERROR: parser: parse error at or near "distinct" > > What Postgres version are you running? Support for count(d

Re: [SQL] count( distinct x )

2000-11-27 Thread Tom Lane
Anthony <[EMAIL PROTECTED]> writes: > select count( distinct area ) from areapostcode where postcode like > 'BS1%' > the above statement fails with > ERROR: parser: parse error at or near "distinct" What Postgres version are you running? Support for count(distinct foo) was added in 7.0,

Re: [SQL] count( distinct x )

2000-11-27 Thread Anthony
Kenn Thompson wrote: > What about > > select count(*) from (select distinct area from areapostcode where postcode like >'BS1%') > select count(*) from (select distinct area from areapostcode where postcode like 'BS1%'); ERROR: parser: parse error at or near "select" Thanks, any more ideas? >

Re: [SQL] count( distinct x )

2000-11-27 Thread Anthony
Michael Fork wrote: > I think you want > > SELECT count(distinct(area)) FROM areapostcode WHERE postcode LIKE 'BS1%' > psql still not happy :( SELECT count(distinct(area)) FROM areapostcode WHERE postcode LIKE 'BS1%'; ERROR: parser: parse error at or near "distinct" Thanks, Bap. > > Michael

Re: [SQL] count( distinct x )

2000-11-27 Thread Michael Fork
I think you want SELECT count(distinct(area)) FROM areapostcode WHERE postcode LIKE 'BS1%' Michael Fork - CCNA - MCP - A+ Network Support - Toledo Internet Access - Toledo Ohio On Mon, 27 Nov 2000, Anthony wrote: > Apologies if this has been asked b4, but got this result when > attemplting to

Re: [SQL] count( distinct x )

2000-11-27 Thread Anthony
Jose Rodrigo Fernandez Menegazzo wrote: > > The problem I have is with this statement: > > > > select count( distinct area ) from areapostcode where postcode like > > 'BS1%' > > > > the above statement fails with > > ERROR: parser: parse error at or near "distinct" > > > > I am not the g

Re: [SQL] count( distinct x )

2000-11-27 Thread Jose Rodrigo Fernandez Menegazzo
> The problem I have is with this statement: > > select count( distinct area ) from areapostcode where postcode like > 'BS1%' > > the above statement fails with > ERROR: parser: parse error at or near "distinct" > > I am not the greatest when it comes to SQL, but the pgsql docs implied >

[SQL] count( distinct x )

2000-11-27 Thread Anthony
Apologies if this has been asked b4, but got this result when attemplting to search the archives on the website Not Found The requested URL /mhonarc/pgsql-sql/search.cgi was not found on this server. Apache/1.3.12 Server at postgresql.rmplc.co.uk Port 80 The problem I have is with this statem