Friday, April 18, 2014

SQL code for World_Fact_RAW

UPDATE tblCountry
SET InternetUsersNumber = 0
WHERE (((tblCountry.[InternetUsers])='NA' Or (tblCountry.[InternetUsers]) Is Null Or (tblCountry.[InternetUsers])='0'));




SELECT tblCountry.InternetUsers
FROM tblCountry
WHERE InStr([InternetUsers],'million')>0;


SELECT tblCountry.InternetUsers
FROM tblCountry
WHERE InStr([InternetUsers],'(')>0;

UPDATE tblCountry
SET InternetUsersNumber = Left([Population],InStr([InternetUsers],'(')-2)
WHERE InStr([InternetUsers],'(')>0;

UPDATE tblCountry
SET InternetUsersNumber = Left([InternetUsers],InStr([InternetUsers],'million')-2) * 1000000
WHERE InStr([InternetUsers],'million')>0;

SELECT Population
FROM tblCountry
WHERE InStr([Population],'(')>0;


UPDATE tblCountry
SET PopulationNumber = Left([Population],InStr([Population],'(')-2)
WHERE InStr([Population],'(')>0;

UPDATE tblCountry
SET PopulationNumber = Left([Population],InStr([Population],'no')-2)
WHERE InStr([Population],'no')>0;


UPDATE tblCountry
SET PopulationNumber = Population;
222 Records
13 Succeeded
209 Failed
172 successes
1 fail
37 Records left to update
36
2 fields


SELECT tblCountry.PopulationNumber, tblCountry.InternetUsersNumber
FROM tblCountry
ORDER BY tblCountry.InternetUsersNumber DESC;


UPDATE tblCountry
SET [Percent] = ([InternetUsersNumber] / [PopulationNumber])*100;

No comments:

Post a Comment