Solved

percentage growth of the last 30 days compared to the total

Posted on 2008-06-09
4
1,491 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 15

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sql Audit table 3 74
Grid querry results 41 80
date diff with Fiscal Calendar 4 52
What is this datetime? 1 18
This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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