Gossamer Forum
Quote Reply
Help on COUNT DISTINCT
Hi, can someone point me the right sintax fo use in LinksSQL for the following?

select COUNT(DISTINCT LinkOwner) from Links

What I want is this:

User with listings:<%total_owners%>
using
Code:
sub {
my $total = $DB->table('Links')->count ( ['DISTINCT(LinkOwner)'] );
return $total;
}
but doesn't work...

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Blondies can have brains (sometimes...)

Last edited by:

SaraBem: Mar 6, 2007, 6:10 PM
Quote Reply
Re: [SaraBem] Help on COUNT DISTINCT In reply to
Hi,

Try:

Code:
sub {
return $DB->table('Links')->select ( ['COUNT(DISTINCT(LinkOwner))'] )->fetchrow || 0;
}

Seems to work ok when I tested just now :) Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Help on COUNT DISTINCT In reply to
Hy Andy, this is the code I already use, but seems redundant to use SELECT when we already have the COUNT...

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Blondies can have brains (sometimes...)