in reply to Please provide a hint for me to continue with the rest of my program
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Please provide a hint for me to continue with the rest of my program
by Yary (Pilgrim) on Apr 24, 2013 at 12:21 UTC | |
by NetWallah (Canon) on Apr 24, 2013 at 13:33 UTC | |
|
Re^2: Please provide a hint for me to continue with the rest of my program
by pooyan (Initiate) on Apr 25, 2013 at 22:10 UTC | |
by Yary (Pilgrim) on Apr 26, 2013 at 14:44 UTC |