Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old March 19th, 2004, 06:56 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
Need help for counting data

Hello everyone, I'm not that good with SQL, but have a basic understanding. This is my request:

I have 1 DB with 2 tables, List1 & List2, each with 25 emails.


EXAMPLE

list1:

user@aol.com
user2@aol.com
user3@aol.com
user1@hotmail.com
user2@hotmail.com
user3@hotmail.com
user4@hotmail.com
user@yahoo.com


list2:

user3@aol.com
user2@aol.com
user4@hotmail.com
user@yahoo.com


What I want to do is to make a union and output this:

+-----------------------------------------------+
|Domain |List1 | List2 | 1-2 | % Opened |
+-----------------------------------------------+
|aol.com | 3 | 2 | 1 | 66% |
|hotmail.com | 4 | 1 | 3 | 25% |
|yahoo.com | 1 | 1 | 0 | 100% |
+-----------------------------------------------+

+ the domain column will be domains encounter
+ the List1 column will be total number of domains encounter for each domain, example found 3 for aol.com
+ the List2 column will be number of domains encounter in list 2, for example: found 2 for aol.com in list 2
+ the colums 1-2 will be the substraction, this I can handle it
+ the last column will be the percentage and also can handle it.


I can't understand how I can do the 3 first steps. Can someone help me? Is this possible? Thank you, and look forward to this

Reply With Quote
  #2  
Old March 19th, 2004, 06:36 PM
-vertigo- -vertigo- is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Louth, Lincolnshire
Posts: 314 -vertigo- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 24 sec
Reputation Power: 2
RE: Need help for counting data

It won't be too easy to do what you want to do. The problem is that you don't know what URL's are in the database. For example, to count how many 'aol.com' addresses there are, you would use something like:

select count(*) from list1 where link LIKE '%@aol.com';

Unfortunately, you don't know what sites have been clicked on. You can't do a 'select distinct' because the links aren't distinct because of the initial part of the email addresses.

I don't know if there are string-manipulation functions in MYSQL that could trim only the domain name so you could use simply count them on-the-fly. If they are such functions then you can do it without too much trouble, because you could select distinct domains from the tables, then use these domains in the 'like' part to count them in each table.

Another way is to seperate the user part from the domain name before you insert the data, where you store the domain names in their own table and the other table has a foreign key to the domain. This is probably a better idea, because you can group by the foreign key when counting the number in each, which is very easy. I would do it this way, as it makes things much easier in the end.

I am sorry if this is too little detail, if it is please ask more about it.

Reply With Quote
  #3  
Old March 19th, 2004, 08:33 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: Need help for counting data

You could use the SUBSTRING_INDEX() function to seperate the email addresses. Have a look at the MySQL manual for proper usage.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Need help for counting data


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway