Gossamer Forum
Skip to Content



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.com

Merry Xmas and a Happy New Year!


Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Custom Toolbar for IE and Firefox! - Compare our different Plugin packages *new*
Free CSS Templates
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...)