Solved

percentage growth of the last 30 days compared to the total

Posted on 2008-06-09
4
1,488 Views
Last Modified: 2012-06-21
Given a table 'mailing':

CREATE TABLE mailing (
      addr VARCHAR(255) NOT NULL
);

The mailing table will initially be empty.  

New addresses will be added on a daily basis.  

It is expected that the table will store at least 10,000,000 email addresses and 100,000 domains.

Write a script in perl or python that updates

      another table which holds a daily count of email addresses by their domain name.

Use this table to report the top 50 domains by count
      sorted by percentage growth of the last 30 days compared to the total.
** NOTE **

- The original mailing table should not be modified.

- All processing must be done in Perl or Python (eg. no complex queries or sub-queries)

- Submit a compressed file(tar/zip) with the files required to run your script.
0
Comment
Question by:amirmaster
  • 2
4 Comments
 
LVL 14

Expert Comment

by:rob_farley
ID: 21829452
This sounds like an exam question. And it's not a SQL question if you're not allowed to do use a query to do the work.

In SQL, you could easily query the top 50 by count, joining it back to a query which counted the ones that appeared more than 30 days ago, ordering by one divided by the other. But that's not what this (exam) question is asking - it wants you to do in perl, and I doubt you'll get many marks when your instructor finds you've given a result posted on the web.

Rob
0
 

Author Comment

by:amirmaster
ID: 22852042
I did it my self
0
 

Accepted Solution

by:
amirmaster earned 0 total points
ID: 22852091
select top 50 from mailing where
id in (
          select top 30 from mailing where datediff(date,getdate())<30 order by date
       )
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now