rulururu

post Calculating amount/percentage of unique domains in email addresses with SQL

March 22nd, 2010

Filed under: Advice, Tip — Zinchenko Oleg @ 5:16 pm

Hello, this is my first technical english post so do not read it very criticaly. I want to describe interesting task with SQL which I faced with.

I have a table with next columns: id, email, etc.

id email etc
1 example@yahoo.com
2 example@gmail.com
90000 example@hotmail.com

I need to calculate quantity of each e-mail domain, calculate percent of domain and sort this information.

Solution:

SELECT
    domain,
    total,
    (total / emailscount) * 100 AS domainpercentage
FROM
    (
        SELECT
        SUBSTRING_INDEX(email, '@', -1) AS domain,
        COUNT(contacts_list.id) AS total,
        (
            SELECT COUNT(cl.id)
            FROM contacts_list AS cl
        ) AS emailscount
        FROM contacts_list
        GROUP BY domain
        ORDER BY total DESC
    ) AS result

Explanation:
At first I select all domains and quantity of their entries.

SELECT
    SUBSTRING_INDEX(email, '@', -1) AS domain,
    COUNT(contacts_list.id) AS total,
    (
        SELECT COUNT(cl.id)
        FROM contacts_list AS cl
    ) AS emailscount
FROM contacts_list
GROUP BY domain
ORDER BY total DESC

Also I select amount of all entries in my table via inner query.

(
    SELECT COUNT(cl.id)
    FROM contacts_list AS cl
) AS emailscount

Then I wrap my query where I select inner`s query results and calculate percentage of each domain.

SELECT
    domain,
    total,
    (total / emailscount) * 100 AS domainpercentage
FROM
(...
) AS result

post Blank screen while Wordpress installation ?

March 4th, 2010

Filed under: Tip, Wordpress — Alex Bylim @ 7:04 pm

There is situation: you install new wordpress blog, insert config data but when it goes to the http://[yourdomain]/wp-admin/install.php you get just blank screen. There can be few reasons, but when it’s your first installation probably you have memory limit issue on you server. You can fix this by adding line below in your .htaccess file:

# increase memory up to 32 mb, if you need you can make this amount bigger

php_value memory_limit 32M

If this does not helps, then you should add this line to your .htaccess file:

php_value display_errors  ”1″

This will force PHP to show what error cause blank screen, and when you know problem it’s easy to find solution

post Wordpress auto-update through FTP fails?

March 4th, 2010

Filed under: Tip, Wordpress — Alex Bylim @ 6:57 pm

While in admin panel of wordpress you are trying to updatd some plugin through auto-update feature does it fails ? You getting something like this: Can not connect ftp …:21 ? You insert all valid data: FTP domain, ftp user, password, choose option through FTP or Secured-FTP and it’s breaks again? Then you should to try enter localhost instead of your actuall ftp domain, it should fix problem.

post Popular technologies

March 3rd, 2010

Filed under: Tip — Alex Bylim @ 8:03 pm

Do you want to learn some new technology and of course receive money in the future for your knowledges ? But you don’t know what technology is popular and relevant? Then you can visit http://www.odesk.com/trends (oDesk one of the most popular web-site for job searching) On Trends page you can see different graphics of what technology is growing and what becoming less popular. From this you can decide where to spend your time :)

ruldrurd
Powered by WordPress, Web Design by Laurentiu Piron
Entries (RSS) and Comments (RSS)