Solved

percentage growth of the last 30 days compared to the total

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

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

831 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