Updated variant:

### getting totalcount:
                                       my $sth = DBSelect("
                                               SELECT
                                                       SUM(`Count`) AS
TotalCount
                                               FROM
                                                       greylisting_tracking
                                               WHERE
                                                       TrackKey =
".DBQuote($key)."
                                                       AND FirstSeen
>= ".DBQuote($addedTime)."
                                       ");

...
                                       my $totalCount =
defined($row->{'totalcount'}) ? $row->{'totalcount'} : 0;


### getting failcount:
                                               $sth = DBSelect("
                                                       SELECT

SUM(Tries)  AS FailCount
                                                       FROM

greylisting_tracking
                                                       WHERE

TrackKey = ".DBQuote($key)."
                                                               AND
FirstSeen >= ".DBQuote($addedTime)."
                                                               AND Count = 0
                                               ");
                                                       my $percentage
= ( 1 - $failCount / $totalCount ) * 100;

2011/5/17 Alexey Murz Korepov <[email protected]>:
> ### getting totalcount:
>                                        my $sth = DBSelect("
>                                                SELECT
>                                                        SUM(`Count`) AS 
> TotalCount
>                                                FROM
>                                                        greylisting_tracking
>                                                WHERE
>                                                        TrackKey = 
> ".DBQuote($key)."
>                                                        AND FirstSeen >= 
> ".DBQuote($addedTime)."
>                                        ");
>
> ...
>                                        my $totalCount = 
> defined($row->{'totalcount'}) ? $row->{'totalcount'} : 0;
>
>
> ### getting failcount:
>                                                $sth = DBSelect("
>                                                        SELECT
>                                                                SUM(Tries)  AS 
> PassCount
>                                                        FROM
>                                                                
> greylisting_tracking
>                                                        WHERE
>                                                                TrackKey = 
> ".DBQuote($key)."
>                                                                AND FirstSeen 
> >= ".DBQuote($addedTime)."
>                                                                AND Count != 0
>                                                ");
>



-- 
Best regards,
Alexey Murz Korepov.
Email, Jabber: [email protected]
_______________________________________________
Users mailing list
[email protected]
http://lists.policyd.org/mailman/listinfo/users

Reply via email to