After that, the storage, and top-50 selection becomes easy. Here is the relevant SQL...my @domain_counts = GUI::DB::query ( $dbh, "SELECT date(now()), substr(addr,locate('@',addr)+1) as maildomain +, count (*) as mailcount FROM mailing GROUP BY maildomain ORDER BY mailcount DESC" );
Of course, the e-mail splitting at the first '@' is not the worlds most robust implementation, but given the other artificial constraints imposed, it should suffice.INSERT INTO dailydomaincounts (maldate,maildomain,mailcount) VALUES +(?,?,?); SELECT SUM(mailcount) as TOTAL from dailymailcounts WHERE maildate >= date(now()) - INTERVAL(30 days); SELECT maildomain, sum(mailcount) * 100.0 / $total as monthlymailpct + from dailymailcounts WHERE maildate >= date(now()) - INTERVAL(30 days) GROUP BY maildomain ORDER BY monthlymailpct DESC LIMIT 50;
SQL "query complexity" is a rather vague, subjective term - I do not consider the above queries to be "complex".
"I'm fairly sure if they took porn off the Internet, there'd only be one website left, and it'd be called 'Bring Back the Porn!'"
-- Dr. Cox, Scrubs
In reply to Re: Please provide a hint for me to continue with the rest of my program
by NetWallah
in thread Please provide a hint for me to continue with the rest of my program
by pooyan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |