0% found this document useful (0 votes)
20 views4 pages

ODM 212 Practical 1

Uploaded by

Yusuph
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views4 pages

ODM 212 Practical 1

Uploaded by

Yusuph
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

THE OPEN UNIVERSITY OF

TANZANIA

FACULT OF SCIENCE, TECHNOLOGY AND ENVIRONMENTAL


STUDIES

DEPARTMENT OF INFORMATION AND COMMUNICATION


TECHNOLOGY

NAME OF THE COURSE DATA MINING AND DATA WAREHOUSE

COURSE CODE ODM - 212

CENTRE LINDI

NAME IDDI, YUSUPH ABDALLAH

REGISTRATION U21-516-0134

PROGRAM BSC. IN INFORMATION AND COMMUNICATION


TECHNOLOGY

WORK TYPE PRACTICAL 01


Question:

You are the IT Specialist of the Ministry of Energy Resource of Tanzania. You are recently
tasked by the CAG of Tanzania to validate the revenue records of Acacia Gold Mining after its
riffle with the government regarding its annual Sales of gold for the year 2016. Acacia is allowed
to sell only two types of Gold (white and Gold). Acacia keeps a ledger of all its customers and
their original countries in the same database with their sales. Acacia has given you a copy of its
database for auditing. Also, one of the customers of Acacia is called Lim Teik from Malaysia
whom the country suspects is having illegal dealings in the country.

1. Create a new table using extended query to summarize all the sales of the company so that a
report showing the total sales to each country

2. Create a table to summarize all the sales of Carat 9 in the year 2016 organized by Supplier.

3. Find how much gold Lim Teik bought and how much he spent in the month of June 2016.

Tables

1. Sales - Customize

2. Customer (customerID, customerName, address)

3. Gold (goldID, typeID, StockAmount)

4. Country (countryID, contryName, continent, NoOfCustomers)

5. Types (typeID, color, description, density)


i. To create a new table summarizing the total sales to each country, we need to join the Sales,
Customer, and Country tables. We can use the following query:

CREATE TABLE SalesSummaryByCountry AS SELECT c.countryName,


SUM(s.salesAmount) AS totalSales FROM Sales s JOIN Customer c ON
s.customerID = c.customerID JOIN Country co ON c.countryID =
co.countryID GROUP BY c.countryName;

This query creates a new table called SalesSummaryByCountry with two columns:
countryName and totalSales. It calculates the total sales amount for each country by
joining the Sales, Customer, and Country tables and grouping the results by countryName.

ii. To create a table summarizing the sales of Carat 9 in the year 2016 organized by Supplier,
we need to join the Sales, Gold, and Customer tables. We can use the following query:

CREATE TABLE Carat9SalesBySupplier AS SELECT c.customerName,


g.supplier, SUM(s.salesAmount) AS totalSales FROM Sales s JOIN
Gold g ON s.goldID = g.goldID JOIN Customer c ON s.customerID =
c.customerID WHERE g.typeID = 'Carat 9' AND YEAR(s.salesDate) =
2016 GROUP BY c.customerName, g.supplier;

This query creates a new table called Carat9SalesBySupplier with three columns:
customerName, supplier, and totalSales. It calculates the total sales amount of
Carat 9 in the year 2016 for each customer and supplier by joining the Sales, Gold, and
Customer tables, filtering for Carat 9 gold and sales in 2016, and grouping the results by
customerName and supplier.
iii. To find out how much gold Lim Teik bought and how much he spent in the month of June
2016, we need to join the Sales, Gold, and Customer tables. We can use the following query:

SELECT g.typeID, s.salesAmount FROM Sales s JOIN Gold g ON


s.goldID = g.goldID JOIN Customer c ON s.customerID =
c.customerID WHERE c.customerName = 'Lim Teik' AND
MONTH(s.salesDate) = 6 AND YEAR(s.salesDate) = 2016;

This query retrieves the typeID and salesAmount from the Sales and Gold tables for
Lim Teik's purchases in the month of June 2016. It joins the Sales, Gold, and Customer
tables, filters for Lim Teik as the customer and sales in June 2016, and returns the results.

You might also like