You are on page 1of 29

SQL

IMPLEMENTATION
FOR NORTHWIND
DATABASE
Lowig Caesar B21220026 Anastasia Valentina B21220027 Deyla Soegiono
B21220029
NORTHWIND COMPANY
Multinational USA-UK Trading Company that
ABOUT carries out Export and Import activities for Food
Products

OrderID CategoryID
CustomerID EmployeeID
PRIMARY CustomerTypeID TerritoryID
KEY SupplierID RegionID
ProductID ShipperID
01
EMPLOYEE
Q1 - Employee’s Territory and Regional
First Name Title Territory Region

Nancy Sales Representative Wilton Eastern

Andrew Vice President, Sales Westboro Eastern

Janet Sales Representative Savannah Southern

Margaret employees.Title,
SELECT employees.FirstName, Sales Representative Greensboro
territories.TerritoryDescription, Eastern
region.RegionDescription GOAL : To gain history information about
employee’s Territory and Regional
FROM ((employees INNER JOIN employeeterritories ON employees.EmployeeID =
Michael
employeeterritories.EmployeeID) INNER Sales
JOINRepresentative
territories ON Phoenix Western
employeeterritories.TerritoryID = territories.TerritoryID) INNER JOIN region ON
territories.RegionID = region.RegionID;
Q2 - Average Salary For Each Region

SELECT region.RegionDescription, Avg(employees.Salary) AS


Region Description Avg Of Salary
AvgOfSalary
Southern 3119,15
FROM ((territories INNER JOIN employeeterritories ON
Northern 2248,66 territories.TerritoryID = employeeterritories.TerritoryID) INNER
JOIN employees ON employeeterritories.EmployeeID =
Eastern 2078,06 employees.EmployeeID) INNER JOIN region ON
territories.RegionID = region.RegionID
Westerns 1995,72
GROUP BY region.RegionDescription;

GOAL: Strive for a fair amount of


salary for all regions
Q3 - Title of Employees for
Every Region Region Description Title

Eastern Sales Manager


SELECT region.RegionDescription, employees.Title
Eastern Sales Representative
FROM ((region INNER JOIN territories ON region.RegionID =
territories.RegionID) INNER JOIN employeeterritories ON Eastern Vice President, Sales
territories.TerritoryID = employeeterritories.TerritoryID) INNER
JOIN employees ON employeeterritories.EmployeeID = Northern Inside Sales Coordinator
employees.EmployeeID
Northern Sales Representative

GROUP BY region.RegionDescription, employees.Title;


Southern Sales Representative

GOAL: to identify staff title for every region Westerns Sales Representative
Q4 - Total Income of Employee
First Name Sum Of Total
SELECT employees.FirstName, Sum([order details].Total) AS
Margaret 250,187.45 SumOfTotal
Janet 213,051.30 FROM (employees INNER JOIN orders ON
employees.EmployeeID = orders.EmployeeID) INNER JOIN
Nancy 202,143.71 [order details] ON orders.OrderID = [order details].OrderID
Andrew 177,749.26 GROUP BY employees.FirstName;
Robert 141,295.99

Laura 133,301.03 GOAL : To gain information about total Gross Income


of each Employee
Anne 82,964.00

Michael 78,198.10

Steven 75,567.75
ContactTitle SumOfTotal
Q5 - Total Income of Employee
Sales Manager 245830
(Divided by Job Title)
Sales Representative 243314

Accounting Manager 243265 SELECT customers.ContactTitle, Sum([order details].Total) AS


SumOfTotal
Owner 188439
FROM (customers INNER JOIN orders ON
Sales Associate 111352 customers.CustomerID = orders.CustomerID) INNER JOIN
Marketing Manager
[order details] ON orders.OrderID = [order details].OrderID
96480

Marketing Assistant 74382 GROUP BY customers.ContactTitle;

Assistant Sales 52247 GOAL : To gain information about total Income of


Representative
Employee for specific job title
Sales Agent 40674

Order Administrator 30730

Assistant Sales Agent 24592

Owner/Marketing Assistant 3160


Q6 - Employee and Supplier Relationship
First Name Product Name Category Supplier Company

Steven Mozzarella di Giovanni Dairy Products Formaggi Fortini s.r.l.

Michael Tofu Produce Mayumi's

Margaret Jack's New England Clam Chowder Seafood New England Seafood Cannery

Margaret Louisiana Fiery Hot Pepper Sauce Condiments New Orleans Cajun Delights

Janet Gustaf's Knckebrd Grains/Cereals PB Knckebrd AB

SELECT employees.FirstName, products.ProductName, categories.CategoryName,


suppliers.CompanyName

FROM (employees INNER JOIN (((orders INNER JOIN [order details] ON


GOAL : To gain history information about
orders.OrderID = [order details].OrderID) INNER JOIN products ON [order
employee and supplier
details].ProductID = products.ProductID) INNER JOIN suppliers ON
products.SupplierID = suppliers.SupplierID) ON employees.EmployeeID =
orders.EmployeeID) INNER JOIN categories ON products.CategoryID =
categories.CategoryID;
Q7 - Employee and Customer Relationship
First Name OrderID Customers Company OrderDate Shippers Company

Steven 10248 Vins et alcools Chevalier 07/04/1996 Federal Shipping

Michael 10249 Toms Spezialitten 07/05/1996 Speedy Express

Margaret 10250 Hanari Carnes 07/08/1996 United Package

Janet 10251 Victuailles en stock 07/08/1996 Speedy Express

Margaret 10252 Suprmes dlices 07/09/1996 United Package

SELECT employees.FirstName, orders.OrderID, customers.CompanyName,


orders.OrderDate, shippers.CompanyName
GOAL : To gain information about
FROM ((employees INNER JOIN orders ON employees.EmployeeID =
customer’s history order and which
orders.EmployeeID) INNER JOIN customers ON orders.CustomerID =
employee is responsible for the order
customers.CustomerID) INNER JOIN shippers ON orders.ShipVia =
shippers.ShipperID;
02
PRODUCT
Q8 - Correlation Between Suppliers & Categories
CompanyName CategoryName SumOfQuantity SELECT suppliers.CompanyName,
categories.CategoryName, Sum([order
Specialty Biscuits, Ltd. Confections 31624 details].Quantity) AS SumOfQuantity

Bigfoot Breweries Beverages 28596 FROM (products AS products_1 INNER JOIN


((suppliers INNER JOIN products ON
Norske Meierier Dairy Products 27447 suppliers.SupplierID = products.SupplierID) INNER
JOIN categories ON products.CategoryID =
Formaggi Fortini s.r.l. Dairy Products 27447 categories.CategoryID) ON products_1.CategoryID =
categories.CategoryID) INNER JOIN [order details]
Heli Swaren GmbH & Confections 23718 ON products_1.ProductID = [order details].ProductID
Co. KG
GROUP BY suppliers.CompanyName,
Svensk Sjfda AB Seafood 23043 categories.CategoryName, suppliers.SupplierID;

New Orleans Cajun Condiments 21192


GOAL : To find out which suppliers supply most of
Delights
product categories
Q9 - The Most Sold Product in Territory Product Sum Of Company Name
Description Name Quantity
Each Territory Atlanta Boston Crab 393 New England
SELECT territories.TerritoryDescription, products.ProductName, Meat Seafood Cannery
Sum([order details].Quantity) AS SumOfQuantity,
Atlanta Camembert 364 Gai pturage
suppliers.CompanyName Pierrot

FROM ((((territories INNER JOIN employeeterritories ON Atlanta Chai 125 Exotic Liquids
territories.TerritoryID = employeeterritories.TerritoryID) INNER
Atlanta Chartreuse 109 Aux joyeux
JOIN orders ON employeeterritories.EmployeeID = verte ecclsiastiques
orders.EmployeeID) INNER JOIN [order details] ON
orders.OrderID = [order details].OrderID) INNER JOIN products Atlanta Cte de Blaye 103 Aux joyeux
ON [order details].ProductID = products.ProductID) INNER JOIN ecclsiastiques
suppliers ON products.SupplierID = suppliers.SupplierID Atlanta Escargots de 145 Escargots
Bourgogne Nouveaux
GROUP BY territories.TerritoryDescription, products.ProductName,
Atlanta Filo Mix 173 G'day, Mate
suppliers.CompanyName

HAVING (((Sum([order details].Quantity))>100)); Atlanta Flotemysost 160 Norske Meierier

TUJUAN: To identify stock needed for all territories


CategoryName Count Of Product ID Q10 - Count of Product for each
Beverages 12 category
Condiments 12

Confections 13 SELECT categories.CategoryName, Count(products.ProductID)


AS CountOfProductID
Dairy Products 10

Grains/Cereals 7 FROM categories INNER JOIN products ON


categories.CategoryID = products.CategoryID
Meat/Poultry 6
GROUP BY categories.CategoryName;
Produce 5

Seafood 12 GOAL: to add more product variation for each category


Q11 - Total Quantity of Each Product
Product Name Quantity Unit

Camembert Pierrot 1,577 15 - 300 g rounds

Raclette Courdavault 1,496 5 kg pkg. SELECT products.ProductName, Sum([order details].Quantity)


AS SumOfQuantity, products.QuantityPerUnit

Gorgonzola Telino 1,397 12 - 100 g pkgs FROM [order details] INNER JOIN products ON [order
details].ProductID = products.ProductID
Gnocchi di nonna 1,263 24 - 250 g pkgs.
Alice
GROUP BY products.ProductName, products.QuantityPerUnit;
Pavlova 1,158 32 - 500 g boxes

Rhnbru Klosterbier 1,155 24 - 0.5 l bottles GOAL : To gain information about total quantity
order of each product
Guaran Fantstica 1,125 12 - 355 ml cans

Boston Crab Meat 1,103 24 - 4 oz tins

Tarte au sucre 1,083 48 pies

Chang 1,057 24 - 12 oz bottles


Q12 - Product’s Origin and Destination
Product Name Category Name Supplier Country Customer Country

Queso Cabrales Dairy Products Spain France

Tofu Produce Japan Germany

Gustaf's Knckebrd Grains/Cereals Sweden France

Sir Rodney's Marmalade Confections UK Belgium

Gorgonzola Telino Dairy Products Italy Brazil

SELECT products.ProductName, categories.CategoryName, suppliers.Country,


orders.ShipCountry

FROM (((orders INNER JOIN [order details] ON orders.OrderID = [order


GOAL : To gain information about origin
details].OrderID) INNER JOIN products ON [order details].ProductID =
and destination of each product and
products.ProductID) INNER JOIN suppliers ON products.SupplierID =
category
suppliers.SupplierID) INNER JOIN categories ON products.CategoryID =
categories.ID;
Units In Stock Units On Order Ratio Sisa
Produk

39 0 0

Q13 - Remaining Product Ratio 17 40 2

13 70 5

53 0 0
UPDATE products SET products.RatioSisaProduk =
0 0
UnitsonOrder/UnitsinStock;
120 0 0

15 0 0

GOAL: to review the ratio of product stock and product 6 0 0


demand
29 0 0
Territory Description Company
Name
Product Name Ratio Sisa
Produk
Q14 - Increase / Decrease Product
Atlanta Aux joyeux
ecclsiastiques
Chartreuse
verte
0 Prices
SELECT territories.TerritoryDescription,
suppliers.CompanyName, products.ProductName,
Atlanta Aux joyeux Cte de Blaye 0
ecclsiastiques products.RatioSisaProduk
Atlanta Bigfoot Laughing 0
Breweries Lumberjack FROM ((((territories INNER JOIN employeeterritories ON
Lager
territories.TerritoryID = employeeterritories.TerritoryID) INNER
Atlanta Bigfoot Sasquatch Ale 0 JOIN orders ON employeeterritories.EmployeeID =
Breweries orders.EmployeeID) INNER JOIN [order details] ON
Atlanta Bigfoot Steeleye Stout 0
orders.OrderID = [order details].OrderID) INNER JOIN
Breweries products ON [order details].ProductID = products.ProductID)
Atlanta Cooperativa Queso
INNER JOIN suppliers ON products.SupplierID =
0
de Quesos 'Las Manchego La suppliers.SupplierID
Cabras' Pastora

Atlanta Escargots Escargots de 0 GROUP BY territories.TerritoryDescription,


Nouveaux Bourgogne
suppliers.CompanyName, products.ProductName,
Atlanta Exotic Liquids Chai 0 products.RatioSisaProduk

HAVING (((products.RatioSisaProduk)<0.5));
GOAL: to find out which products need to be given a discounted price
Q15 - Increase / Decrease Product
Prices
Territory Company Name Product Name Ratio Sisa
Description Produk
SELECT territories.TerritoryDescription,
Atlanta Exotic Liquids Aniseed Syrup 5 suppliers.CompanyName, products.ProductName,
products.RatioSisaProduk
Atlanta Formaggi Fortini s.r.l. Mascarpone 4
Fabioli
FROM ((((territories INNER JOIN employeeterritories ON
Atlanta Karkki Oy Maxilaku 6 territories.TerritoryID = employeeterritories.TerritoryID) INNER
JOIN orders ON employeeterritories.EmployeeID =
Atlanta Lyngbysild Rogede sild 14
orders.EmployeeID) INNER JOIN [order details] ON
orders.OrderID = [order details].OrderID) INNER JOIN
Atlanta New Orleans Cajun Louisiana Hot 25
Delights Spiced Okra products ON [order details].ProductID = products.ProductID)
INNER JOIN suppliers ON products.SupplierID =
Atlanta Plutzer Wimmers gute 4
Lebensmittelgromrkte AG Semmelkndel suppliers.SupplierID
Atlanta Specialty Biscuits, Ltd. Sir Rodney's 13
Scones GROUP BY territories.TerritoryDescription,
suppliers.CompanyName, products.ProductName,
Atlanta Tokyo Traders Longlife Tofu 5 products.RatioSisaProduk

HAVING (((products.RatioSisaProduk)>3));
GOAL: to find out which products should be increased
Q16 - Total Income of Each Product Category

Category Name Sum Of Total SELECT categories.CategoryName, Sum([order details].Total)


AS SumOfTotal
Beverages 286,526.95
FROM ((orders INNER JOIN [order details] ON
Dairy Products 251,330.50 orders.OrderID = [order details].OrderID) INNER JOIN
products ON [order details].ProductID = products.ProductID)
Meat/Poultry INNER JOIN categories ON products.CategoryID =
178,188.80
categories.CategoryID
Confections 177,099.10
GROUP BY categories.CategoryName;
Seafood 141,623.09 GOAL : To gain information about total Gross Income
of each product category
Condiments 113,694.75

Produce 105,268.60

Grains/Cereals 100,726.80
03
ORDER
CountOfOrderID Country
Q17 - Total Order
122 USA
(Divided by Country)
122 Germany
SELECT Count(orders.OrderID) AS CountOfOrderID,
customers.Country 83 Brazil

FROM orders INNER JOIN customers ON orders.CustomerID = 77 France


customers.CustomerID
56 UK
GROUP BY customers.Country;
46 Venezuela
GOAL : To find out customer from which country order the most or
the least from our company 40 Austria

37 Sweden

30 Canada

28 Mexico

28 Italy
Q17 - Total Order CountOfOrderID Country

(Divided by Country) 23 Spain

22 Finland
SELECT Count(orders.OrderID) AS CountOfOrderID,
customers.Country 19 Belgium

FROM orders INNER JOIN customers ON orders.CustomerID = 19 Ireland


customers.CustomerID
18 Denmark
GROUP BY customers.Country;
18 Switzerland
GOAL : To find out customer from which country order the most or
the least from our company 16 Argentina

13 Portugal

7 Poland

6 Norway
Q18 - Count of Order for each employee
Region Employee ID Count Of
Description Order ID
SELECT region.RegionDescription, orders.EmployeeID,
Eastern 1 246 Count(orders.OrderID) AS CountOfOrderID
Eastern 2 672
FROM (((region INNER JOIN territories ON region.RegionID =
Eastern 4 468 territories.RegionID) INNER JOIN employeeterritories ON
territories.TerritoryID = employeeterritories.TerritoryID) INNER
Eastern 5 294 JOIN employees ON employeeterritories.EmployeeID =
employees.EmployeeID) INNER JOIN orders ON
Northern 8 416 employees.EmployeeID = orders.EmployeeID
Northern 9 301
GROUP BY region.RegionDescription, orders.EmployeeID;
Southern 3 508
GOAL: to evaluated the achievement of the staff
Westerns 6 335

Westerns 7 720
Q19 - Employee vs Order
Region Count Of Sum Of Count
Description Employee ID Of Order ID
SELECT [3a].RegionDescription, Count([3a].EmployeeID) AS
CountOfEmployeeID, Sum([3a].CountOfOrderID) AS Eastern 4 1680
SumOfCountOfOrderID
Northern 2 717
FROM 3a
Southern 1 508
GROUP BY [3a].RegionDescription; Westerns 2 1055

GOAL: to evaluate the capacity of staff in each region based on the


amount of the order on each region
04
SHIPPING
Country SumOfFreight Country SumOfFreight
Q20 - Total Freight
USA 13771.29 Switzerland 1368.53
(divided by Country)
Germany 11283.28 Belgium 1280.14
SELECT customers.Country,
Austria 7391.5 Mexico 1122.78 Sum(orders.Freight) AS SumOfFreight

Brazil 4880.19 Finland 910.89 FROM (customers INNER JOIN orders ON


customers.CustomerID =
France 4237.84 Italy 864.44 orders.CustomerID) INNER JOIN shippers
ON orders.ShipVia = shippers.ShipperID
Sweden 3237.6 Spain 861.89
GROUP BY customers.Country;
UK 2954.27 Portugal 643.53

Ireland 2755.24 Argentina 598.58 GOAL : To gain information about which country
spend more freight for their order from our
Venezuela 2735.18 Norway 275.5 company

Canada 2198.09 Poland 175.74

Denmark 1396.19
Q21 - Total Freight of Shipping Company

SELECT shippers.CompanyName, Sum(orders.Freight) AS


CompanyName SumOfFreight SumOfFreight

United Package 28244,85 FROM INNER JOIN shippers ON orders.ShipVia =


shippers.ShipperID
Federal Shipping 20512,51
GROUP BY shippers.CompanyName;
Speedy Express 16185,33
GOAL : To gain information about which shipping
company gain more freight cost from our company
THANKYOU
GOD BLESS YOU

You might also like