Solved

percentage growth of the last 30 days compared to the total

Posted on 2008-06-09
4
1,492 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
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…

740 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