Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalized code for the class. #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions -- SQLite-1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- SQLite
SELECT a.*,b.*
FROM vwCUSTOMER_BIRTHDATE a
INNER JOIN vwCUSTOMER_ADDRESS b
ON a.CustomerKey = b.CustomerKey
7 changes: 7 additions & 0 deletions -- SQLite-2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- SQLite
SELECT a.*,b.* FROM
DimCustomer a
INNER JOIN
FactInternetSales b
ON a.CustomerKey = b.CustomerKey
ORDER BY a.CustomerKey;
8 changes: 8 additions & 0 deletions -- SQLite-3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- SQLite
SELECT a.*, b.*
FROM
FactInternetSales a
INNER JOIN
FactSurveyResponse b
ON
a.OrderDate = b.Date
6 changes: 6 additions & 0 deletions -- SQLite-4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- SQLite
SELECT A.EnglishProductName, B.EnglishProductName, A.ProductSubcategoryKey
FROM DimProduct A
INNER JOIN DimProduct B
ON A.ProductKey <> B.ProductKey
ORDER BY A.ProductSubcategoryKey;
29 changes: 29 additions & 0 deletions -- SQLite-5.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- SQLite
DROP VIEW customer_email_a;
CREATE VIEW customer_email_a AS
SELECT CustomerKey, EmailAddress FROM DimCustomer
WHERE EmailAddress like '%a%adventure_works.com';

DROP VIEW customer_address_us;
CREATE VIEW customer_address_us AS
SELECT CustomerKey, AddressLine1, AddressLine2, C.GeographyKey FROM DimCustomer C
JOIN DimGeography G ON C.GeographyKey = G.GeographyKey
WHERE CountryRegionCode = 'US';

SELECT C.CustomerKey,C.FirstName, C.LastName, A.EmailAddress, B.GeographyKey
FROM DimCustomer C
LEFT JOIN customer_email_a as A
ON C.CustomerKey = A.CustomerKey
LEFT JOIN customer_address_us as B
ON C.CustomerKey = B.CustomerKey;

SELECT p.ProductKey, sum(s.SalesAmount) AS Sum_of_Sales
FROM DimProduct p
LEFT JOIN FactInternetSales s USING(ProductKey)
GROUP BY p.ProductKey;

SELECT DimProduct.ProductKey, DimProduct.EnglishProductName, FactInternetSales.OrderDate, FactInternetSales.OrderQuantity, FactInternetSales.SalesAmount
FROM DimProduct
LEFT JOIN FactInternetSales
ON DimProduct.ProductKey = FactInternetSales.ProductKey
ORDER BY DimProduct.ProductKey;
22 changes: 22 additions & 0 deletions -- SQLite-complex-joins.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- SQLite
SELECT
ResellerName,
AddressLine1,
AddressLine2,
G.City,
G.StateProvinceCode,
G.PostalCode,
G.CountryRegionCode,
S.ProductKey,
P.ProductSubcategoryKey,
S.SalesAmount
FROM
DimReseller as R
LEFT JOIN FactResellerSales as S
ON R.ResellerKey = S.ResellerKey
INNER JOIN DimGeography as G
on R.GeographyKey = G.GeographyKey
LEFT JOIN DimProduct as P
on S.ProductKey = P.ProductKey
WHERE G.CountryRegionCode = 'US'
ORDER BY S.SalesAmount ASC;
3 changes: 3 additions & 0 deletions -- SQLite-cross-joins.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- SQLite
SELECT *
FROM DimCurrency CROSS JOIN DimDepartmentGroup;
11 changes: 11 additions & 0 deletions -- SQLite-full-outer-joins.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- SQLite
SELECT a.*,b.*
FROM
customer_address_us a
LEFT JOIN FactInternetSales b
ON a.CustomerKey = b.CustomerKey
UNION
SELECT a.*,b.*
FROM FactInternetSales b
LEFT JOIN customer_address_us a
ON a.CustomerKey = b.CustomerKey;
12 changes: 12 additions & 0 deletions -- SQLite-right-joins.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- SQLite
SELECT p.ProductKey,
p.EnglishProductName, s.*
FROM DimProduct p
LEFT JOIN FactInternetSales s ON p.ProductKey = s.ProductKey;

SELECT
p.ProductKey,
p.EnglishProductName,
s.*
FROM FactInternetSales s
LEFT JOIN DimProduct p ON p.ProductKey = s.ProductKey;
8 changes: 8 additions & 0 deletions -- SQLite.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- SQLite
SELECT
name
FROM
sqlite_master
WHERE
type = 'table' AND name NOT LIKE 'sqlite_%';

9 changes: 9 additions & 0 deletions -- SQLite_self_joins.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- SQLite
SELECT E.EmployeeKey AS EmployeeKey,
E.FirstName AS Employee_First_Name,
E.LastName AS Employee_Last_Name,
M.FirstName AS Manager_First_Name,
M.LastName AS Manager_Last_Name
FROM DimEmployee E
JOIN DimEmployee M
ON E.ParentEmployeeKey = M.EmployeeKey;
Loading