diff --git a/AdventureWorksLT_ER.pdf b/AdventureWorksLT_ER.pdf new file mode 100644 index 0000000..1cea171 Binary files /dev/null and b/AdventureWorksLT_ER.pdf differ diff --git a/DataCamp-SQL.pdf b/DataCamp-SQL.pdf new file mode 100644 index 0000000..020d0e4 Binary files /dev/null and b/DataCamp-SQL.pdf differ diff --git a/Demos/Mod01_Demos.zip b/Demos/Mod01_Demos.zip new file mode 100644 index 0000000..4549277 Binary files /dev/null and b/Demos/Mod01_Demos.zip differ diff --git a/Demos/Mod02_Demos.zip b/Demos/Mod02_Demos.zip new file mode 100644 index 0000000..2f35550 Binary files /dev/null and b/Demos/Mod02_Demos.zip differ diff --git a/Demos/Mod03_Demos.zip b/Demos/Mod03_Demos.zip new file mode 100644 index 0000000..b4f99ff Binary files /dev/null and b/Demos/Mod03_Demos.zip differ diff --git a/Demos/Mod04_Demos.zip b/Demos/Mod04_Demos.zip new file mode 100644 index 0000000..8cd04bd Binary files /dev/null and b/Demos/Mod04_Demos.zip differ diff --git a/Demos/Mod05_Demos.zip b/Demos/Mod05_Demos.zip new file mode 100644 index 0000000..9f77a6a Binary files /dev/null and b/Demos/Mod05_Demos.zip differ diff --git a/Demos/Mod06_Demos.zip b/Demos/Mod06_Demos.zip new file mode 100644 index 0000000..d590405 Binary files /dev/null and b/Demos/Mod06_Demos.zip differ diff --git a/Demos/Mod07_Demos.zip b/Demos/Mod07_Demos.zip new file mode 100644 index 0000000..5ff8cd4 Binary files /dev/null and b/Demos/Mod07_Demos.zip differ diff --git a/Demos/Mod08_Demos.zip b/Demos/Mod08_Demos.zip new file mode 100644 index 0000000..bd2bc68 Binary files /dev/null and b/Demos/Mod08_Demos.zip differ diff --git a/Demos/Mod09_Demos.zip b/Demos/Mod09_Demos.zip new file mode 100644 index 0000000..fe14f72 Binary files /dev/null and b/Demos/Mod09_Demos.zip differ diff --git a/Demos/Mod10_Demos.zip b/Demos/Mod10_Demos.zip new file mode 100644 index 0000000..003aae4 Binary files /dev/null and b/Demos/Mod10_Demos.zip differ diff --git a/Demos/Mod11_Demos.zip b/Demos/Mod11_Demos.zip new file mode 100644 index 0000000..c353052 Binary files /dev/null and b/Demos/Mod11_Demos.zip differ diff --git a/Getting Started with DAT201x.pdf b/Getting Started with DAT201x.pdf new file mode 100644 index 0000000..84adb4e Binary files /dev/null and b/Getting Started with DAT201x.pdf differ diff --git a/Getting Started.docx b/Getting Started.docx deleted file mode 100644 index f20b438..0000000 Binary files a/Getting Started.docx and /dev/null differ diff --git a/Labs/Lab01.pdf b/Labs/Lab01.pdf new file mode 100644 index 0000000..2929dec Binary files /dev/null and b/Labs/Lab01.pdf differ diff --git a/Labs/Lab02.pdf b/Labs/Lab02.pdf new file mode 100644 index 0000000..fde5441 Binary files /dev/null and b/Labs/Lab02.pdf differ diff --git a/Labs/Lab03.pdf b/Labs/Lab03.pdf new file mode 100644 index 0000000..dcaabdf Binary files /dev/null and b/Labs/Lab03.pdf differ diff --git a/Labs/Lab04.pdf b/Labs/Lab04.pdf new file mode 100644 index 0000000..741acd3 Binary files /dev/null and b/Labs/Lab04.pdf differ diff --git a/Labs/Lab05.pdf b/Labs/Lab05.pdf new file mode 100644 index 0000000..621f23b Binary files /dev/null and b/Labs/Lab05.pdf differ diff --git a/Labs/Lab06.pdf b/Labs/Lab06.pdf new file mode 100644 index 0000000..8715be7 Binary files /dev/null and b/Labs/Lab06.pdf differ diff --git a/Labs/Lab07.pdf b/Labs/Lab07.pdf new file mode 100644 index 0000000..2c4accf Binary files /dev/null and b/Labs/Lab07.pdf differ diff --git a/Labs/Lab08.pdf b/Labs/Lab08.pdf new file mode 100644 index 0000000..7cfeb34 Binary files /dev/null and b/Labs/Lab08.pdf differ diff --git a/Labs/Lab09.pdf b/Labs/Lab09.pdf new file mode 100644 index 0000000..1d5499a Binary files /dev/null and b/Labs/Lab09.pdf differ diff --git a/Labs/Lab10.pdf b/Labs/Lab10.pdf new file mode 100644 index 0000000..9cd2f5f Binary files /dev/null and b/Labs/Lab10.pdf differ diff --git a/Labs/Lab11.pdf b/Labs/Lab11.pdf new file mode 100644 index 0000000..207ea7e Binary files /dev/null and b/Labs/Lab11.pdf differ diff --git a/MVA Setup Guide.pdf b/MVA Setup Guide.pdf new file mode 100644 index 0000000..ee51eb3 Binary files /dev/null and b/MVA Setup Guide.pdf differ diff --git a/Mod 01 - Introduction to T-SQL/Demos/1-Select.sql b/Mod 01 - Introduction to T-SQL/Demos/1-Select.sql deleted file mode 100644 index 98c661b..0000000 --- a/Mod 01 - Introduction to T-SQL/Demos/1-Select.sql +++ /dev/null @@ -1,18 +0,0 @@ -SELECT Name, StandardCost, ListPrice -FROM SalesLT.Product; - - -SELECT Name, ListPrice - StandardCost -FROM SalesLT.Product; - - -SELECT Name, ListPrice - StandardCost AS Markup -FROM SalesLT.Product; - - -SELECT ProductNumber, Color, Size, Color + ', ' + Size AS ProductDetails -FROM SalesLT.Product; - - -SELECT ProductID + ': ' + Name -FROM SalesLT.Product; diff --git a/Mod 01 - Introduction to T-SQL/Demos/2-Converting Data Types.sql b/Mod 01 - Introduction to T-SQL/Demos/2-Converting Data Types.sql deleted file mode 100644 index 3512b08..0000000 --- a/Mod 01 - Introduction to T-SQL/Demos/2-Converting Data Types.sql +++ /dev/null @@ -1,16 +0,0 @@ -SELECT CAST(ProductID AS varchar(5)) + ': ' + Name AS ProductName -FROM SalesLT.Product; - -SELECT CONVERT(varchar(5), ProductID) + ': ' + Name AS ProductName -FROM SalesLT.Product; - -SELECT SellStartDate, - CONVERT(nvarchar(30), SellStartDate) AS ConvertedDate, - CONVERT(nvarchar(30), SellStartDate, 126) AS ISO8601FormatDate -FROM SalesLT.Product; - -SELECT Name, CAST (Size AS Integer) AS NumericSize -FROM SalesLT.Product; --(note error - some sizes are incompatible) - -SELECT Name, TRY_CAST (Size AS Integer) AS NumericSize -FROM SalesLT.Product; --(note incompatible sizes are returned as NULL) diff --git a/Mod 01 - Introduction to T-SQL/Demos/3-NULLs and Expressions.sql b/Mod 01 - Introduction to T-SQL/Demos/3-NULLs and Expressions.sql deleted file mode 100644 index 41898f2..0000000 --- a/Mod 01 - Introduction to T-SQL/Demos/3-NULLs and Expressions.sql +++ /dev/null @@ -1,30 +0,0 @@ -SELECT Name, ISNULL(TRY_CAST(Size AS Integer),0) AS NumericSize -FROM SalesLT.Product; - -SELECT ProductNumber, ISNULL(Color, '') + ', ' + ISNULL(Size, '') AS ProductDetails -FROM SalesLT.Product; - -SELECT Name, NULLIF(Color, 'Multi') AS SingleColor -FROM SalesLT.Product; - -SELECT Name, COALESCE(DiscontinuedDate, SellEndDate, SellStartDate) AS FirstNonNullDate -FROM SalesLT.Product; - ---Searched case -SELECT Name, - CASE - WHEN SellEndDate IS NULL THEN 'On Sale' - ELSE 'Discontinued' - END AS SalesStatus -FROM SalesLT.Product; - ---Simple case -SELECT Name, - CASE Size - WHEN 'S' THEN 'Small' - WHEN 'M' THEN 'Medium' - WHEN 'L' THEN 'Large' - WHEN 'XL' THEN 'Extra-Large' - ELSE ISNULL(Size, 'n/a') - END AS ProductSize -FROM SalesLT.Product; \ No newline at end of file diff --git a/Mod 01 - Introduction to T-SQL/Lab Solution/1-Customer Data.sql b/Mod 01 - Introduction to T-SQL/Lab Solution/1-Customer Data.sql deleted file mode 100644 index 4df3c83..0000000 --- a/Mod 01 - Introduction to T-SQL/Lab Solution/1-Customer Data.sql +++ /dev/null @@ -1,11 +0,0 @@ - --- Display all columns for all customers -SELECT * FROM SalesLT.Customer; - --- Display customer name fields -SELECT Title, FirstName, MiddleName, LastName, Suffix -FROM SalesLT.Customer; - --- Display title and last name with phone number -SELECT Salesperson, Title + ' ' + LastName AS CustomerName, Phone -FROM SalesLT.Customer; \ No newline at end of file diff --git a/Mod 01 - Introduction to T-SQL/Lab Solution/2-Customer and Sales Data.sql b/Mod 01 - Introduction to T-SQL/Lab Solution/2-Customer and Sales Data.sql deleted file mode 100644 index aab7234..0000000 --- a/Mod 01 - Introduction to T-SQL/Lab Solution/2-Customer and Sales Data.sql +++ /dev/null @@ -1,9 +0,0 @@ --- Customer Companies -SELECT CAST(CustomerID AS varchar) + ': ' + CompanyName AS CustomerCompany -FROM SalesLT.Customer; - ---Sales Order Revisions -SELECT SalesOrderNumber + ' (' + STR(RevisionNumber, 1) + ')' AS OrderRevision, - CONVERT(nvarchar(30), OrderDate, 102) AS OrderDate -FROM SalesLT.SalesOrderHeader; - diff --git a/Mod 01 - Introduction to T-SQL/Lab Solution/3-Customer Contact Details.sql b/Mod 01 - Introduction to T-SQL/Lab Solution/3-Customer Contact Details.sql deleted file mode 100644 index 7b319c9..0000000 --- a/Mod 01 - Introduction to T-SQL/Lab Solution/3-Customer Contact Details.sql +++ /dev/null @@ -1,24 +0,0 @@ --- Get middle names if known -SELECT FirstName + ' ' + ISNULL(MiddleName + ' ', '')+ LastName AS CustomerName -FROM SalesLT.Customer; - --- Get primary contact details -UPDATE SalesLT.Customer -SET EmailAddress = NULL -WHERE CustomerID % 7 = 1; - -SELECT CustomerID, COALESCE(EmailAddress, Phone) AS PrimaryContact -FROM SalesLT.Customer; - --- Get shipping status -UPDATE SalesLT.SalesOrderHeader -SET ShipDate = NULL -WHERE SalesOrderID > 71899; - -SELECT SalesOrderID, OrderDate, - CASE - WHEN ShipDate IS NULL THEN 'Awaiting Shipment' - ELSE 'Shipped' - END AS ShippingStatus -FROM SalesLT.SalesOrderHeader; - diff --git a/Mod 01 - Introduction to T-SQL/Lab01 - Introduction to Transact-SQL.docx b/Mod 01 - Introduction to T-SQL/Lab01 - Introduction to Transact-SQL.docx deleted file mode 100644 index 6215f89..0000000 Binary files a/Mod 01 - Introduction to T-SQL/Lab01 - Introduction to Transact-SQL.docx and /dev/null differ diff --git a/Mod 02 - Querying Tables with SELECT/Demos/1 - Eliminating Duplicates and Sorting Results.sql b/Mod 02 - Querying Tables with SELECT/Demos/1 - Eliminating Duplicates and Sorting Results.sql deleted file mode 100644 index de8ce63..0000000 --- a/Mod 02 - Querying Tables with SELECT/Demos/1 - Eliminating Duplicates and Sorting Results.sql +++ /dev/null @@ -1,21 +0,0 @@ ---Display a list of product colors -SELECT Color FROM SalesLT.Product; - ---Display a list of product colors with the word 'None' if the value is null -SELECT DISTINCT ISNULL(Color, 'None') AS Color FROM SalesLT.Product; - ---Display a list of product colors with the word 'None' if the value is null sorted by color -SELECT DISTINCT ISNULL(Color, 'None') AS Color FROM SalesLT.Product ORDER BY Color; - ---Display a list of product colors with the word 'None' if the value is null and a dash if the size is null sorted by color -SELECT DISTINCT ISNULL(Color, 'None') AS Color, ISNULL(Size, '-') AS Size FROM SalesLT.Product ORDER BY Color; - - ---Display the top 100 products by list price -SELECT TOP 100 Name, ListPrice FROM SalesLT.Product ORDER BY ListPrice DESC; - ---Display the first ten products by product number -SELECT Name, ListPrice FROM SalesLT.Product ORDER BY ProductNumber OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY; - ---Display the next ten products by product number -SELECT Name, ListPrice FROM SalesLT.Product ORDER BY ProductNumber OFFSET 10 ROWS FETCH FIRST 10 ROW ONLY; \ No newline at end of file diff --git a/Mod 02 - Querying Tables with SELECT/Demos/2 - Filtering with Predicates.sql b/Mod 02 - Querying Tables with SELECT/Demos/2 - Filtering with Predicates.sql deleted file mode 100644 index 1b9dc99..0000000 --- a/Mod 02 - Querying Tables with SELECT/Demos/2 - Filtering with Predicates.sql +++ /dev/null @@ -1,23 +0,0 @@ ---List information about product model 6 -SELECT Name, Color, Size FROM SalesLT.Product WHERE ProductModelID = 6; - ---List information about products that have a product number beginning FR -SELECT productnumber,Name, ListPrice FROM SalesLT.Product WHERE ProductNumber LIKE 'FR%'; - ---Filter the previous query to ensure that the product number contains two sets of two didgets -SELECT Name, ListPrice FROM SalesLT.Product WHERE ProductNumber LIKE 'FR-_[0-9][0-9]_-[0-9][0-9]'; - ---Find products that have no sell end date -SELECT Name FROM SalesLT.Product WHERE SellEndDate IS NOT NULL; - ---Find products that have a sell end date in 2006 -SELECT Name FROM SalesLT.Product WHERE SellEndDate BETWEEN '2006/1/1' AND '2006/12/31'; - ---Find products that have a category ID of 5, 6, or 7. -SELECT ProductCategoryID, Name, ListPrice FROM SalesLT.Product WHERE ProductCategoryID IN (5, 6, 7); - ---Find products that have a category ID of 5, 6, or 7 and have a sell end date -SELECT ProductCategoryID, Name, ListPrice, SellEndDate FROM SalesLT.Product WHERE ProductCategoryID IN (5, 6, 7) AND SellEndDate IS NULL; - ---Select products that have a category ID of 5, 6, or 7 and a product number that begins FR -SELECT Name, ProductCategoryID, ProductNumber FROM SalesLT.Product WHERE ProductNumber LIKE 'FR%' OR ProductCategoryID IN (5,6,7); \ No newline at end of file diff --git a/Mod 02 - Querying Tables with SELECT/Lab Solution/1-Transportation Reports.sql b/Mod 02 - Querying Tables with SELECT/Lab Solution/1-Transportation Reports.sql deleted file mode 100644 index 230f673..0000000 --- a/Mod 02 - Querying Tables with SELECT/Lab Solution/1-Transportation Reports.sql +++ /dev/null @@ -1,10 +0,0 @@ ---Retrieve City List -SELECT DISTINCT City, StateProvince -FROM SalesLT.Address - ---Retrieve Heaviest Products -SELECT TOP 10 PERCENT Name FROM SalesLT.Product ORDER BY Weight DESC; - ---Retrieve the Heaviest 100 Products Not Including the Heaviest Ten -SELECT Name FROM SalesLT.Product ORDER BY Weight DESC -OFFSET 10 ROWS FETCH NEXT 100 ROWS ONLY; \ No newline at end of file diff --git a/Mod 02 - Querying Tables with SELECT/Lab Solution/2-Product Data.sql b/Mod 02 - Querying Tables with SELECT/Lab Solution/2-Product Data.sql deleted file mode 100644 index a775110..0000000 --- a/Mod 02 - Querying Tables with SELECT/Lab Solution/2-Product Data.sql +++ /dev/null @@ -1,19 +0,0 @@ ---Retrieve Product Details -SELECT Name, Color, Size -FROM SalesLT.Product -WHERE ProductModelID = 1; - ---Retrieve Products by Color and Size -SELECT ProductNumber, Name -FROM SalesLT.Product -WHERE Color IN ('Black','Red','White') and Size IN ('S','M'); - ---Retrieve Products by Product Number -SELECT ProductNumber, Name, ListPrice -FROM SalesLT.Product -WHERE ProductNumber LIKE 'BK-%'; - ---Retrieve Specific Products by Product Number -SELECT ProductNumber, Name, ListPrice -FROM SalesLT.Product -WHERE ProductNumber LIKE 'BK-[^R]%-[0-9][0-9]'; diff --git a/Mod 02 - Querying Tables with SELECT/Lab02 - Querying Tables with SELECT.docx b/Mod 02 - Querying Tables with SELECT/Lab02 - Querying Tables with SELECT.docx deleted file mode 100644 index c7512e3..0000000 Binary files a/Mod 02 - Querying Tables with SELECT/Lab02 - Querying Tables with SELECT.docx and /dev/null differ diff --git a/Mod 03 - Querying Multiple Tables With Joins/Demos/01-Inner Joins.sql b/Mod 03 - Querying Multiple Tables With Joins/Demos/01-Inner Joins.sql deleted file mode 100644 index 34f196a..0000000 --- a/Mod 03 - Querying Multiple Tables With Joins/Demos/01-Inner Joins.sql +++ /dev/null @@ -1,29 +0,0 @@ ---Basic inner join -SELECT SalesLT.Product.Name As ProductName, SalesLT.ProductCategory.Name AS Category -FROM SalesLT.Product -INNER JOIN SalesLT.ProductCategory -ON SalesLT.Product.ProductCategoryID = SalesLT.ProductCategory.ProductCategoryID; - --- Table aliases -SELECT p.Name As ProductName, c.Name AS Category -FROM SalesLT.Product AS p -JOIN SalesLT.ProductCategory As c -ON p.ProductCategoryID = c.ProductCategoryID; - --- Joining more than 2 tables -SELECT oh.OrderDate, oh.SalesOrderNumber, p.Name As ProductName, od.OrderQty, od.UnitPrice, od.LineTotal -FROM SalesLT.SalesOrderHeader AS oh -JOIN SalesLT.SalesOrderDetail AS od -ON od.SalesOrderID = oh.SalesOrderID -JOIN SalesLT.Product AS p -ON od.ProductID = p.ProductID -ORDER BY oh.OrderDate, oh.SalesOrderID, od.SalesOrderDetailID; - --- Multiple join predicates -SELECT oh.OrderDate, oh.SalesOrderNumber, p.Name As ProductName, od.OrderQty, od.UnitPrice, od.LineTotal -FROM SalesLT.SalesOrderHeader AS oh -JOIN SalesLT.SalesOrderDetail AS od -ON od.SalesOrderID = oh.SalesOrderID -JOIN SalesLT.Product AS p -ON od.ProductID = p.ProductID AND od.UnitPrice = p.ListPrice --Note multiple predicates -ORDER BY oh.OrderDate, oh.SalesOrderID, od.SalesOrderDetailID; diff --git a/Mod 03 - Querying Multiple Tables With Joins/Demos/02-Outer Joins.sql b/Mod 03 - Querying Multiple Tables With Joins/Demos/02-Outer Joins.sql deleted file mode 100644 index e5bd76c..0000000 --- a/Mod 03 - Querying Multiple Tables With Joins/Demos/02-Outer Joins.sql +++ /dev/null @@ -1,35 +0,0 @@ ---Get all customers, with sales orders for those who've bought anything -SELECT c.FirstName, c.LastName, oh.SalesOrderNumber -FROM SalesLT.Customer AS c -LEFT OUTER JOIN SalesLT.SalesOrderHeader AS oh -ON c.CustomerID = oh.CustomerID -ORDER BY c.CustomerID; - ---Return only customers who haven't purchased anything -SELECT c.FirstName, c.LastName, oh.SalesOrderNumber -FROM SalesLT.Customer AS c -LEFT OUTER JOIN SalesLT.SalesOrderHeader AS oh -ON c.CustomerID = oh.CustomerID -WHERE oh.SalesOrderNumber IS NULL -ORDER BY c.CustomerID; - - ---More than 2 tables -SELECT p.Name As ProductName, oh.SalesOrderNumber -FROM SalesLT.Product AS p -LEFT JOIN SalesLT.SalesOrderDetail AS od -ON p.ProductID = od.ProductID -LEFT JOIN SalesLT.SalesOrderHeader AS oh --Additional tables added to the right must also use a left join -ON od.SalesOrderID = oh.SalesOrderID -ORDER BY p.ProductID; - - -SELECT p.Name As ProductName, c.Name AS Category, oh.SalesOrderNumber -FROM SalesLT.Product AS p -LEFT OUTER JOIN SalesLT.SalesOrderDetail AS od -ON p.ProductID = od.ProductID -LEFT OUTER JOIN SalesLT.SalesOrderHeader AS oh -ON od.SalesOrderID = oh.SalesOrderID -INNER JOIN SalesLT.ProductCategory AS c --Added to the left, so can use inner join -ON p.ProductCategoryID = c.ProductCategoryID -ORDER BY p.ProductID; diff --git a/Mod 03 - Querying Multiple Tables With Joins/Demos/03-Cross Join.sql b/Mod 03 - Querying Multiple Tables With Joins/Demos/03-Cross Join.sql deleted file mode 100644 index 3be934e..0000000 --- a/Mod 03 - Querying Multiple Tables With Joins/Demos/03-Cross Join.sql +++ /dev/null @@ -1,4 +0,0 @@ ---Call each customer once per product -SELECT p.Name, c.FirstName, c.LastName, c.Phone -FROM SalesLT.Product as p -CROSS JOIN SalesLT.Customer as c; diff --git a/Mod 03 - Querying Multiple Tables With Joins/Demos/04-Self Join.sql b/Mod 03 - Querying Multiple Tables With Joins/Demos/04-Self Join.sql deleted file mode 100644 index bca6d1d..0000000 --- a/Mod 03 - Querying Multiple Tables With Joins/Demos/04-Self Join.sql +++ /dev/null @@ -1,23 +0,0 @@ ---note there's no employee table, so we'll create one for this example -CREATE TABLE SalesLT.Employee -(EmployeeID int IDENTITY PRIMARY KEY, -EmployeeName nvarchar(256), -ManagerID int); -GO --- Get salesperson from Customer table and generate managers -INSERT INTO SalesLT.Employee (EmployeeName, ManagerID) -SELECT DISTINCT Salesperson, NULLIF(CAST(RIGHT(SalesPerson, 1) as INT), 0) -FROM SalesLT.Customer; -GO -UPDATE SalesLT.Employee -SET ManagerID = (SELECT MIN(EmployeeID) FROM SalesLT.Employee WHERE ManagerID IS NULL) -WHERE ManagerID IS NULL -AND EmployeeID > (SELECT MIN(EmployeeID) FROM SalesLT.Employee WHERE ManagerID IS NULL); -GO - --- Here's the actual self-join demo -SELECT e.EmployeeName, m.EmployeeName AS ManagerName -FROM SalesLT.Employee AS e -LEFT JOIN SalesLT.Employee AS m -ON e.ManagerID = m.EmployeeID -ORDER BY e.ManagerID; diff --git a/Mod 03 - Querying Multiple Tables With Joins/Lab Solution/01-Invoice Reports.sql b/Mod 03 - Querying Multiple Tables With Joins/Lab Solution/01-Invoice Reports.sql deleted file mode 100644 index 5b9c3fe..0000000 --- a/Mod 03 - Querying Multiple Tables With Joins/Lab Solution/01-Invoice Reports.sql +++ /dev/null @@ -1,17 +0,0 @@ --- Customer Orders -SELECT c.CompanyName, oh.SalesOrderID, oh.TotalDue -FROM SalesLT.Customer AS c -JOIN SalesLT.SalesOrderHeader AS oh -ON oh.CustomerID = c.CustomerID; - --- Customer Orders with Addresses -SELECT c.CompanyName, a.AddressLine1, ISNULL(a.AddressLine2, '') AS AddressLine2, - a.City, a.StateProvince, a.PostalCode, a.CountryRegion, oh.SalesOrderID, oh.TotalDue -FROM SalesLT.Customer AS c -JOIN SalesLT.SalesOrderHeader AS oh -ON oh.CustomerID = c.CustomerID -JOIN SalesLT.CustomerAddress AS ca -ON c.CustomerID = ca.CustomerID AND AddressType = 'Main Office' -JOIN SalesLT.Address AS a -ON ca.AddressID = a.AddressID; - diff --git a/Mod 03 - Querying Multiple Tables With Joins/Lab Solution/02-Sales Reports.sql b/Mod 03 - Querying Multiple Tables With Joins/Lab Solution/02-Sales Reports.sql deleted file mode 100644 index 35b5da9..0000000 --- a/Mod 03 - Querying Multiple Tables With Joins/Lab Solution/02-Sales Reports.sql +++ /dev/null @@ -1,25 +0,0 @@ --- All customers and their orders -SELECT c.CompanyName, c.FirstName, c.LastName, oh.SalesOrderID, oh.TotalDue -FROM SalesLT.Customer AS c -LEFT JOIN SalesLT.SalesOrderHeader AS oh -ON c.CustomerID = oh.CustomerID -ORDER BY oh.SalesOrderID DESC; - --- Customers with no address -SELECT c.CompanyName, c.FirstName, c.LastName, c.Phone -FROM SalesLT.Customer AS c -LEFT JOIN SalesLT.CustomerAddress AS ca -ON c.CustomerID = ca.CustomerID -WHERE ca.AddressID IS NULL; - --- Customers and products for which there are no orders -SELECT c.CustomerID, p.ProductID -FROM SalesLT.Customer AS c -FULL JOIN SalesLT.SalesOrderHeader AS oh -ON c.CustomerID = oh.CustomerID -FULL JOIN SalesLT.SalesOrderDetail AS od -ON od.SalesOrderID = oh.SalesOrderID -FULL JOIN SalesLT.Product AS p -ON p.ProductID = od.ProductID -WHERE oh.SalesOrderID IS NULL -ORDER BY ProductID, CustomerID; diff --git a/Mod 03 - Querying Multiple Tables With Joins/Lab03 - Querying Multiple Tables with Joins.docx b/Mod 03 - Querying Multiple Tables With Joins/Lab03 - Querying Multiple Tables with Joins.docx deleted file mode 100644 index e320ceb..0000000 Binary files a/Mod 03 - Querying Multiple Tables With Joins/Lab03 - Querying Multiple Tables with Joins.docx and /dev/null differ diff --git a/Mod 04 - Using Set Operators/Demos/1 - Union.sql b/Mod 04 - Using Set Operators/Demos/1 - Union.sql deleted file mode 100644 index 47ba112..0000000 --- a/Mod 04 - Using Set Operators/Demos/1 - Union.sql +++ /dev/null @@ -1,25 +0,0 @@ --- Setup -CREATE VIEW [SalesLT].[Customers] -as -select distinct firstname,lastname -from saleslt.customer -where lastname >='m' -or customerid=3; -GO -CREATE VIEW [SalesLT].[Employees] -as -select distinct firstname,lastname -from saleslt.customer -where lastname <='m' -or customerid=3; -GO - --- Union example -SELECT FirstName, LastName -FROM SalesLT.Employees -UNION -SELECT FirstName, LastName -FROM SalesLT.Customers -ORDER BY LastName; - - diff --git a/Mod 04 - Using Set Operators/Demos/2 - Intersect.sql b/Mod 04 - Using Set Operators/Demos/2 - Intersect.sql deleted file mode 100644 index 16fa172..0000000 --- a/Mod 04 - Using Set Operators/Demos/2 - Intersect.sql +++ /dev/null @@ -1,5 +0,0 @@ -SELECT FirstName, LastName -FROM SalesLT.Customers -INTERSECT -SELECT FirstName, LastName -FROM SalesLT.Employees; diff --git a/Mod 04 - Using Set Operators/Demos/3 - Except.sql b/Mod 04 - Using Set Operators/Demos/3 - Except.sql deleted file mode 100644 index b211902..0000000 --- a/Mod 04 - Using Set Operators/Demos/3 - Except.sql +++ /dev/null @@ -1,6 +0,0 @@ -SELECT FirstName, LastName -FROM SalesLT.Customers -EXCEPT -SELECT FirstName, LastName -FROM SalesLT.Employees; - diff --git a/Mod 04 - Using Set Operators/Lab Solution/1 - Customer Addresses.sql b/Mod 04 - Using Set Operators/Lab Solution/1 - Customer Addresses.sql deleted file mode 100644 index 4b6fd84..0000000 --- a/Mod 04 - Using Set Operators/Lab Solution/1 - Customer Addresses.sql +++ /dev/null @@ -1,36 +0,0 @@ --- Billing addresses -SELECT c.CompanyName, a.AddressLine1, a.City, 'Billing' AS AddressType -FROM SalesLT.Customer AS c -JOIN SalesLT.CustomerAddress AS ca -ON c.CustomerID = ca.CustomerID -JOIN SalesLT.Address AS a -ON ca.AddressID = a.AddressID -WHERE ca.AddressType = 'Main Office'; - --- Shipping addresses -SELECT c.CompanyName, a.AddressLine1, a.City, 'Shipping' AS AddressType -FROM SalesLT.Customer AS c -JOIN SalesLT.CustomerAddress AS ca -ON c.CustomerID = ca.CustomerID -JOIN SalesLT.Address AS a -ON ca.AddressID = a.AddressID -WHERE ca.AddressType = 'Shipping'; - --- All customer addresses -SELECT c.CompanyName, a.AddressLine1, a.City, 'Billing' AS AddressType -FROM SalesLT.Customer AS c -JOIN SalesLT.CustomerAddress AS ca -ON c.CustomerID = ca.CustomerID -JOIN SalesLT.Address AS a -ON ca.AddressID = a.AddressID -WHERE ca.AddressType = 'Main Office' -UNION ALL -SELECT c.CompanyName, a.AddressLine1, a.City, 'Shipping' AS AddressType -FROM SalesLT.Customer AS c -JOIN SalesLT.CustomerAddress AS ca -ON c.CustomerID = ca.CustomerID -JOIN SalesLT.Address AS a -ON ca.AddressID = a.AddressID -WHERE ca.AddressType = 'Shipping' -ORDER BY c.CompanyName, AddressType; - diff --git a/Mod 04 - Using Set Operators/Lab Solution/2 - Filtering Customer Addresses.sql b/Mod 04 - Using Set Operators/Lab Solution/2 - Filtering Customer Addresses.sql deleted file mode 100644 index fbb9f3a..0000000 --- a/Mod 04 - Using Set Operators/Lab Solution/2 - Filtering Customer Addresses.sql +++ /dev/null @@ -1,35 +0,0 @@ --- Customers with only a main office address -SELECT c.CompanyName -FROM SalesLT.Customer AS c -JOIN SalesLT.CustomerAddress AS ca -ON c.CustomerID = ca.CustomerID -JOIN SalesLT.Address AS a -ON ca.AddressID = a.AddressID -WHERE ca.AddressType = 'Main Office' -EXCEPT -SELECT c.CompanyName -FROM SalesLT.Customer AS c -JOIN SalesLT.CustomerAddress AS ca -ON c.CustomerID = ca.CustomerID -JOIN SalesLT.Address AS a -ON ca.AddressID = a.AddressID -WHERE ca.AddressType = 'Shipping' -ORDER BY c.CompanyName; - --- Only customers with both a main office and a shipping address -SELECT c.CompanyName -FROM SalesLT.Customer AS c -JOIN SalesLT.CustomerAddress AS ca -ON c.CustomerID = ca.CustomerID -JOIN SalesLT.Address AS a -ON ca.AddressID = a.AddressID -WHERE ca.AddressType = 'Main Office' -INTERSECT -SELECT c.CompanyName -FROM SalesLT.Customer AS c -JOIN SalesLT.CustomerAddress AS ca -ON c.CustomerID = ca.CustomerID -JOIN SalesLT.Address AS a -ON ca.AddressID = a.AddressID -WHERE ca.AddressType = 'Shipping' -ORDER BY c.CompanyName; \ No newline at end of file diff --git a/Mod 04 - Using Set Operators/Lab04 - Using Set Operators.docx b/Mod 04 - Using Set Operators/Lab04 - Using Set Operators.docx deleted file mode 100644 index 902fd78..0000000 Binary files a/Mod 04 - Using Set Operators/Lab04 - Using Set Operators.docx and /dev/null differ diff --git a/Mod 05 - Using Functions and Aggregating Data/Demos/01-Functions.sql b/Mod 05 - Using Functions and Aggregating Data/Demos/01-Functions.sql deleted file mode 100644 index 9510198..0000000 --- a/Mod 05 - Using Functions and Aggregating Data/Demos/01-Functions.sql +++ /dev/null @@ -1,71 +0,0 @@ --- Scalar functions -SELECT YEAR(SellStartDate) SellStartYear, ProductID, Name -FROM SalesLT.Product -ORDER BY SellStartYear; - -SELECT YEAR(SellStartDate) SellStartYear, DATENAME(mm,SellStartDate) SellStartMonth, - DAY(SellStartDate) SellStartDay, DATENAME(dw, SellStartDate) SellStartWeekday, - ProductID, Name -FROM SalesLT.Product -ORDER BY SellStartYear; - -SELECT DATEDIFF(yy,SellStartDate, GETDATE()) YearsSold, ProductID, Name -FROM SalesLT.Product -ORDER BY ProductID; - -SELECT UPPER(Name) AS ProductName -FROM SalesLT.Product; - -SELECT CONCAT(FirstName + ' ', LastName) AS FullName -FROM SalesLT.Customer; - -SELECT Name, ProductNumber, LEFT(ProductNumber, 2) AS ProductType -FROM SalesLT.Product; - -SELECT Name, ProductNumber, LEFT(ProductNumber, 2) AS ProductType, - SUBSTRING(ProductNumber,CHARINDEX('-', ProductNumber) + 1, 4) AS ModelCode, - SUBSTRING(ProductNumber, LEN(ProductNumber) - CHARINDEX('-', REVERSE(RIGHT(ProductNumber, 3))) + 2, 2) AS SizeCode -FROM SalesLT.Product; - - --- Logical functions -SELECT Name, Size AS NumericSize -FROM SalesLT.Product -WHERE ISNUMERIC(Size) = 1; - -SELECT Name, IIF(ProductCategoryID IN (5,6,7), 'Bike', 'Other') ProductType -FROM SalesLT.Product; - -SELECT Name, IIF(ISNUMERIC(Size) = 1, 'Numeric', 'Non-Numeric') SizeType -FROM SalesLT.Product; - -SELECT prd.Name AS ProductName, cat.Name AS Category, - CHOOSE (cat.ParentProductCategoryID, 'Bikes','Components','Clothing','Accessories') AS ProductType -FROM SalesLT.Product AS prd -JOIN SalesLT.ProductCategory AS cat -ON prd.ProductCategoryID = cat.ProductCategoryID; - - --- Window functions -SELECT TOP(100) ProductID, Name, ListPrice, - RANK() OVER(ORDER BY ListPrice DESC) AS RankByPrice -FROM SalesLT.Product AS p -ORDER BY RankByPrice; - -SELECT c.Name AS Category, p.Name AS Product, ListPrice, - RANK() OVER(PARTITION BY c.Name ORDER BY ListPrice DESC) AS RankByPrice -FROM SalesLT.Product AS p -JOIN SalesLT.ProductCategory AS c -ON p.ProductCategoryID = c.ProductcategoryID -ORDER BY Category, RankByPrice; - - --- Aggregate Functions -SELECT COUNT(*) AS Products, COUNT(DISTINCT ProductCategoryID) AS Categories, AVG(ListPrice) AS AveragePrice -FROM SalesLT.Product; - -SELECT COUNT(p.ProductID) BikeModels, AVG(p.ListPrice) AveragePrice -FROM SalesLT.Product AS p -JOIN SalesLT.ProductCategory AS c -ON p.ProductCategoryID = c.ProductCategoryID -WHERE c.Name LIKE '%Bikes'; \ No newline at end of file diff --git a/Mod 05 - Using Functions and Aggregating Data/Demos/02-Group By.sql b/Mod 05 - Using Functions and Aggregating Data/Demos/02-Group By.sql deleted file mode 100644 index 04d9b56..0000000 --- a/Mod 05 - Using Functions and Aggregating Data/Demos/02-Group By.sql +++ /dev/null @@ -1,32 +0,0 @@ -SELECT Salesperson, COUNT(CustomerID) Customers -FROM SalesLT.Customer -GROUP BY Salesperson -ORDER BY Salesperson; - -SELECT c.Name AS Category, COUNT(p.ProductID) AS Products -FROM SalesLT.Product AS p -JOIN SalesLT.ProductCategory AS c -ON p.ProductCategoryID = c.ProductCategoryID -GROUP BY c.Name -ORDER BY Category; - -SELECT c.Salesperson, SUM(oh.SubTotal) SalesRevenue -FROM SalesLT.Customer c -JOIN SalesLT.SalesOrderHeader oh -ON c.CustomerID = oh.CustomerID -GROUP BY c.Salesperson -ORDER BY SalesRevenue DESC; - -SELECT c.Salesperson, ISNULL(SUM(oh.SubTotal), 0.00) SalesRevenue -FROM SalesLT.Customer c -LEFT JOIN SalesLT.SalesOrderHeader oh -ON c.CustomerID = oh.CustomerID -GROUP BY c.Salesperson -ORDER BY SalesRevenue DESC; - -SELECT c.Salesperson, CONCAT(c.FirstName +' ', c.LastName) AS Customer, ISNULL(SUM(oh.SubTotal), 0.00) SalesRevenue -FROM SalesLT.Customer c -LEFT JOIN SalesLT.SalesOrderHeader oh -ON c.CustomerID = oh.CustomerID -GROUP BY c.Salesperson, CONCAT(c.FirstName +' ', c.LastName) -ORDER BY SalesRevenue DESC, Customer; \ No newline at end of file diff --git a/Mod 05 - Using Functions and Aggregating Data/Demos/03-Having.sql b/Mod 05 - Using Functions and Aggregating Data/Demos/03-Having.sql deleted file mode 100644 index 81ffca2..0000000 --- a/Mod 05 - Using Functions and Aggregating Data/Demos/03-Having.sql +++ /dev/null @@ -1,14 +0,0 @@ --- Try to find salespeople with over 150 customers (fails with error) -SELECT Salesperson, COUNT(CustomerID) Customers -FROM SalesLT.Customer -WHERE COUNT(CustomerID) > 100 -GROUP BY Salesperson -ORDER BY Salesperson; - ---Need to use HAVING clause to filter based on aggregate -SELECT Salesperson, COUNT(CustomerID) Customers -FROM SalesLT.Customer -GROUP BY Salesperson -HAVING COUNT(CustomerID) > 100 -ORDER BY Salesperson; - diff --git a/Mod 05 - Using Functions and Aggregating Data/Lab Solution/1 - Product Data.sql b/Mod 05 - Using Functions and Aggregating Data/Lab Solution/1 - Product Data.sql deleted file mode 100644 index 2cc0420..0000000 --- a/Mod 05 - Using Functions and Aggregating Data/Lab Solution/1 - Product Data.sql +++ /dev/null @@ -1,32 +0,0 @@ ---Retrieve the nname and approximate weight of each product -SELECT ProductID, - UPPER(Name) AS ProductName, - ROUND(Weight, 0) AS ApproxWeight -FROM SalesLT.Product; - ---Retrieve the month and year products were first sold -SELECT ProductID, - UPPER(Name) AS ProductName, - ROUND(Weight, 0) AS ApproxWeight, - YEAR(SellStartDate) as SellStartYear, - DATENAME(m, SellStartDate) as SellStartMonth -FROM SalesLT.Product; - --- Extract type from product number -SELECT ProductID, - UPPER(Name) AS ProductName, - ROUND(Weight, 0) AS ApproxWeight, - YEAR(SellStartDate) as SellStartYear, - DATENAME(m, SellStartDate) as SellStartMonth, - LEFT(ProductNumber, 2) AS ProductType -FROM SalesLT.Product; - --- Filter to include only products with numeric sizes -SELECT ProductID, - UPPER(Name) AS ProductName, - ROUND(Weight, 0) AS ApproxWeight, - YEAR(SellStartDate) as SellStartYear, - DATENAME(m, SellStartDate) as SellStartMonth, - LEFT(ProductNumber, 2) AS ProductType -FROM SalesLT.Product -WHERE ISNUMERIC(Size)=1; diff --git a/Mod 05 - Using Functions and Aggregating Data/Lab Solution/2 - Ranked Customers.sql b/Mod 05 - Using Functions and Aggregating Data/Lab Solution/2 - Ranked Customers.sql deleted file mode 100644 index 53c62d1..0000000 --- a/Mod 05 - Using Functions and Aggregating Data/Lab Solution/2 - Ranked Customers.sql +++ /dev/null @@ -1,7 +0,0 @@ ---Retrieve Companies Ranked by Revenue -SELECT CompanyName, - TotalDue AS Revenue, - RANK() OVER (ORDER BY TotalDue DESC) AS RankByRevenue -FROM SalesLT.SalesOrderHeader AS SOH -JOIN SalesLT.Customer AS C -ON SOH.CustomerID=C.CustomerID; \ No newline at end of file diff --git a/Mod 05 - Using Functions and Aggregating Data/Lab Solution/3 - Product Sales.sql b/Mod 05 - Using Functions and Aggregating Data/Lab Solution/3 - Product Sales.sql deleted file mode 100644 index 27c63db..0000000 --- a/Mod 05 - Using Functions and Aggregating Data/Lab Solution/3 - Product Sales.sql +++ /dev/null @@ -1,23 +0,0 @@ ---Retrieve Total Sales by Product -SELECT Name,SUM(LineTotal) AS TotalRevenue -FROM SalesLT.SalesOrderDetail AS SOD -JOIN SalesLT.Product AS P ON SOD.ProductID=P.ProductID -GROUP BY P.Name -ORDER BY TotalRevenue DESC; - --- Only products that cost over $1,000 -SELECT Name,SUM(LineTotal) AS TotalRevenue -FROM SalesLT.SalesOrderDetail AS SOD -JOIN SalesLT.Product AS P ON SOD.ProductID=P.ProductID -WHERE P.ListPrice > 1000 -GROUP BY P.Name -ORDER BY TotalRevenue DESC; - ---Only groupings with sales totals over $20,000 -SELECT Name,SUM(LineTotal) AS TotalRevenue -FROM SalesLT.SalesOrderDetail AS SOD -JOIN SalesLT.Product AS P ON SOD.ProductID=P.ProductID -WHERE P.ListPrice > 1000 -GROUP BY P.Name -HAVING SUM(LineTotal) > 20000 -ORDER BY TotalRevenue DESC; diff --git a/Mod 05 - Using Functions and Aggregating Data/Lab05 - Using Functions and Aggregating Data.docx b/Mod 05 - Using Functions and Aggregating Data/Lab05 - Using Functions and Aggregating Data.docx deleted file mode 100644 index db67c28..0000000 Binary files a/Mod 05 - Using Functions and Aggregating Data/Lab05 - Using Functions and Aggregating Data.docx and /dev/null differ diff --git a/Mod 06 - Using Subqueries and APPLY/Demos/1 - Scalar Subquery.sql b/Mod 06 - Using Subqueries and APPLY/Demos/1 - Scalar Subquery.sql deleted file mode 100644 index 9c8ee38..0000000 --- a/Mod 06 - Using Subqueries and APPLY/Demos/1 - Scalar Subquery.sql +++ /dev/null @@ -1,11 +0,0 @@ ---Display a list of products whose list price is higher than the highest unit price of items that have sold - -SELECT MAX(UnitPrice) FROM SalesLT.SalesOrderDetail - -SELECT * from SalesLT.Product -WHERE ListPrice > - - -SELECT * from SalesLT.Product -WHERE ListPrice > -(SELECT MAX(UnitPrice) FROM SalesLT.SalesOrderDetail) diff --git a/Mod 06 - Using Subqueries and APPLY/Demos/2 - Multi-Valued Subquery.sql b/Mod 06 - Using Subqueries and APPLY/Demos/2 - Multi-Valued Subquery.sql deleted file mode 100644 index 4e7e7aa..0000000 --- a/Mod 06 - Using Subqueries and APPLY/Demos/2 - Multi-Valued Subquery.sql +++ /dev/null @@ -1,12 +0,0 @@ ---List products that have an order quantity greater than 20 - -SELECT Name FROM SalesLT.Product -WHERE ProductID IN -(SELECT ProductID from SalesLT.SalesOrderDetail -WHERE OrderQty>20) - -SELECT Name -FROM SalesLT.Product P -JOIN SalesLT.SalesOrderDetail SOD -ON P.ProductID=SOD.ProductID -WHERE OrderQty>20 diff --git a/Mod 06 - Using Subqueries and APPLY/Demos/3 - Correlated Subquery.sql b/Mod 06 - Using Subqueries and APPLY/Demos/3 - Correlated Subquery.sql deleted file mode 100644 index a07bbae..0000000 --- a/Mod 06 - Using Subqueries and APPLY/Demos/3 - Correlated Subquery.sql +++ /dev/null @@ -1,20 +0,0 @@ ---For each customer list all sales on the last day that they made a sale - -SELECT CustomerID, SalesOrderID, OrderDate -FROM SalesLT.SalesOrder AS SO1 -ORDER BY CustomerID,OrderDate - -SELECT CustomerID, SalesOrderID, OrderDate -FROM SalesLT.SalesOrder AS SO1 -WHERE orderdate = -(SELECT MAX(orderdate) -FROM SalesLT.SalesOrder) - - -SELECT CustomerID, SalesOrderID, OrderDate -FROM SalesLT.SalesOrder AS SO1 -WHERE orderdate = -(SELECT MAX(orderdate) -FROM SalesLT.SalesOrder AS SO2 -WHERE SO2.CustomerID = SO1.CustomerID) -ORDER BY CustomerID diff --git a/Mod 06 - Using Subqueries and APPLY/Demos/4 - CROSS APPLY.sql b/Mod 06 - Using Subqueries and APPLY/Demos/4 - CROSS APPLY.sql deleted file mode 100644 index 47eb642..0000000 --- a/Mod 06 - Using Subqueries and APPLY/Demos/4 - CROSS APPLY.sql +++ /dev/null @@ -1,16 +0,0 @@ --- Setup -CREATE FUNCTION SalesLT.udfMaxUnitPrice (@SalesOrderID int) -RETURNS TABLE -AS -RETURN -SELECT SalesOrderID,Max(UnitPrice) as MaxUnitPrice FROM -SalesLT.SalesOrderDetail -WHERE SalesOrderID=@SalesOrderID -GROUP BY SalesOrderID; - ---Display the sales order details for items that are equal to --- the maximum unit price for that sales order -SELECT * FROM SalesLT.SalesOrderDetail AS SOH -CROSS APPLY SalesLT.udfMaxUnitPrice(SOH.SalesOrderID) AS MUP -WHERE SOH.UnitPrice=MUP.MaxUnitPrice -ORDER BY SOH.SalesOrderID; diff --git a/Mod 06 - Using Subqueries and APPLY/Lab Solution/1 - Product Price Data.sql b/Mod 06 - Using Subqueries and APPLY/Lab Solution/1 - Product Price Data.sql deleted file mode 100644 index e43da99..0000000 --- a/Mod 06 - Using Subqueries and APPLY/Lab Solution/1 - Product Price Data.sql +++ /dev/null @@ -1,34 +0,0 @@ ---Retrieve Products whose list price is higher than the average unit price in the SalesOrderDetail table -SELECT ProductID, Name, ListPrice from SalesLT.Product -WHERE ListPrice > -(SELECT AVG(UnitPrice) FROM SalesLT.SalesOrderDetail) -ORDER BY ProductID; - ---Retrieve products that are priced $100 or more --- but have sold for a unit price of less than $100 -SELECT ProductID, Name, ListPrice FROM SalesLT.Product -WHERE ProductID IN -(SELECT ProductID from SalesLT.SalesOrderDetail - WHERE UnitPrice < 100.00) -AND ListPrice >= 100.00 -ORDER BY ProductID; - ---Retrieve cost, list price, and average selling price for each product -SELECT ProductID, Name, StandardCost, ListPrice, - (SELECT AVG(UnitPrice) - FROM SalesLT.SalesOrderDetail AS SOD - WHERE P.ProductID = SOD.ProductID) AS AvgSellingPrice -FROM SalesLT.Product AS P -ORDER BY P.ProductID; - ---Find products where the average selling price is less than cost -SELECT ProductID, Name, StandardCost, ListPrice, -(SELECT AVG(UnitPrice) - FROM SalesLT.SalesOrderDetail AS SOD - WHERE P.ProductID = SOD.ProductID) AS AvgSellingPrice -FROM SalesLT.Product AS P -WHERE StandardCost > -(SELECT AVG(UnitPrice) - FROM SalesLT.SalesOrderDetail AS SOD - WHERE P.ProductID = SOD.ProductID) -ORDER BY P.ProductID; \ No newline at end of file diff --git a/Mod 06 - Using Subqueries and APPLY/Lab Solution/2 - Customer Information.sql b/Mod 06 - Using Subqueries and APPLY/Lab Solution/2 - Customer Information.sql deleted file mode 100644 index 09a0e6d..0000000 --- a/Mod 06 - Using Subqueries and APPLY/Lab Solution/2 - Customer Information.sql +++ /dev/null @@ -1,13 +0,0 @@ ---Retrieve sales order data with customer information from a function -SELECT SOH.SalesOrderID, SOH.CustomerID, CI.FirstName, CI.LastName, SOH.TotalDue -FROM SalesLT.SalesOrderHeader AS SOH -CROSS APPLY dbo.ufnGetCustomerInformation(SOH.CustomerID) AS CI -ORDER BY SOH.SalesOrderID; - ---Retrieve addresses with customer information from a function -SELECT CA.CustomerID, CI.FirstName, CI.LastName, A.AddressLine1, A.City -FROM SalesLT.Address AS A -JOIN SalesLT.CustomerAddress AS CA -ON A.AddressID = CA.AddressID -CROSS APPLY dbo.ufnGetCustomerInformation(CA.CustomerID) AS CI -ORDER BY CA.CustomerID; diff --git a/Mod 06 - Using Subqueries and APPLY/Lab06 - Using Subqueries and APPLY.docx b/Mod 06 - Using Subqueries and APPLY/Lab06 - Using Subqueries and APPLY.docx deleted file mode 100644 index 6c9965b..0000000 Binary files a/Mod 06 - Using Subqueries and APPLY/Lab06 - Using Subqueries and APPLY.docx and /dev/null differ diff --git a/Mod 07 - Using Table Expressions/Demos/01-Views.sql b/Mod 07 - Using Table Expressions/Demos/01-Views.sql deleted file mode 100644 index 82bbe3e..0000000 --- a/Mod 07 - Using Table Expressions/Demos/01-Views.sql +++ /dev/null @@ -1,21 +0,0 @@ --- Create a view -CREATE VIEW SalesLT.vCustomerAddress -AS -SELECT C.CustomerID, FirstName, LastName, AddressLine1, City, StateProvince -FROM -SalesLT.Customer C JOIN SalesLT.CustomerAddress CA -ON C.CustomerID=CA.CustomerID -JOIN SalesLT.Address A -ON CA.AddressID=A.AddressID - --- Query the view -SELECT CustomerID, City -FROM SalesLT.vCustomerAddress - --- Join the view to a table -SELECT c.StateProvince, c.City, ISNULL(SUM(s.TotalDue), 0.00) AS Revenue -FROM SalesLT.vCustomerAddress AS c -LEFT JOIN SalesLT.SalesOrderHeader AS s -ON s.CustomerID = c.CustomerID -GROUP BY c.StateProvince, c.City -ORDER BY c.StateProvince, Revenue DESC; diff --git a/Mod 07 - Using Table Expressions/Demos/02-Temp Tables and Variables.sql b/Mod 07 - Using Table Expressions/Demos/02-Temp Tables and Variables.sql deleted file mode 100644 index 8c75bfe..0000000 --- a/Mod 07 - Using Table Expressions/Demos/02-Temp Tables and Variables.sql +++ /dev/null @@ -1,21 +0,0 @@ --- Temporary table -CREATE TABLE #Colors -(Color varchar(15)); - -INSERT INTO #Colors -SELECT DISTINCT Color FROM SalesLT.Product; - -SELECT * FROM #Colors; - --- Table variable -DECLARE @Colors AS TABLE (Color varchar(15)); - -INSERT INTO @Colors -SELECT DISTINCT Color FROM SalesLT.Product; - -SELECT * FROM @Colors; - --- New batch -SELECT * FROM #Colors; - -SELECT * FROM @Colors; -- now out of scope \ No newline at end of file diff --git a/Mod 07 - Using Table Expressions/Demos/03-TVFs.sql b/Mod 07 - Using Table Expressions/Demos/03-TVFs.sql deleted file mode 100644 index 407df7b..0000000 --- a/Mod 07 - Using Table Expressions/Demos/03-TVFs.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE FUNCTION SalesLT.udfCustomersByCity -(@City AS VARCHAR(20)) -RETURNS TABLE -AS -RETURN -(SELECT C.CustomerID, FirstName, LastName, AddressLine1, City, StateProvince - FROM SalesLT.Customer C JOIN SalesLT.CustomerAddress CA - ON C.CustomerID=CA.CustomerID - JOIN SalesLT.Address A ON CA.AddressID=A.AddressID - WHERE City=@City); - - -SELECT * FROM SalesLT.udfCustomersByCity('Bellevue') diff --git a/Mod 07 - Using Table Expressions/Demos/04-Derived Tables.sql b/Mod 07 - Using Table Expressions/Demos/04-Derived Tables.sql deleted file mode 100644 index 2b5682f..0000000 --- a/Mod 07 - Using Table Expressions/Demos/04-Derived Tables.sql +++ /dev/null @@ -1,8 +0,0 @@ -SELECT Category, COUNT(ProductID) AS Products -FROM - (SELECT p.ProductID, p.Name AS Product, c.Name AS Category - FROM SalesLT.Product AS p - JOIN SalesLT.ProductCategory AS c - ON p.ProductCategoryID = c.ProductCategoryID) AS ProdCats -GROUP BY Category -ORDER BY Category; diff --git a/Mod 07 - Using Table Expressions/Demos/05- CTEs.sql b/Mod 07 - Using Table Expressions/Demos/05- CTEs.sql deleted file mode 100644 index ab7f6f2..0000000 --- a/Mod 07 - Using Table Expressions/Demos/05- CTEs.sql +++ /dev/null @@ -1,38 +0,0 @@ ---Using a CTE -WITH ProductsByCategory (ProductID, ProductName, Category) -AS -( - SELECT p.ProductID, p.Name, c.Name AS Category - FROM SalesLT.Product AS p - JOIN SalesLT.ProductCategory AS c - ON p.ProductCategoryID = c.ProductCategoryID -) - -SELECT Category, COUNT(ProductID) AS Products -FROM ProductsByCategory -GROUP BY Category -ORDER BY Category; - - --- Recursive CTE -SELECT * FROM SalesLT.Employee - --- Using the CTE to perform recursion -WITH OrgReport (ManagerID, EmployeeID, EmployeeName, Level) -AS -( - -- Anchor query - SELECT e.ManagerID, e.EmployeeID, EmployeeName, 0 - FROM SalesLT.Employee AS e - WHERE ManagerID IS NULL - - UNION ALL - - -- Recursive query - SELECT e.ManagerID, e.EmployeeID, e.EmployeeName, Level + 1 - FROM SalesLT.Employee AS e - INNER JOIN OrgReport AS o ON e.ManagerID = o.EmployeeID -) - -SELECT * FROM OrgReport -OPTION (MAXRECURSION 3); diff --git a/Mod 07 - Using Table Expressions/Lab Solution/1 - Product Data.sql b/Mod 07 - Using Table Expressions/Lab Solution/1 - Product Data.sql deleted file mode 100644 index d1993e2..0000000 --- a/Mod 07 - Using Table Expressions/Lab Solution/1 - Product Data.sql +++ /dev/null @@ -1,28 +0,0 @@ --- Retrieve product model descriptions -SELECT P.ProductID, P.Name AS ProductName, PM.Name AS ProductModel, PM.Summary -FROM SalesLT.Product AS P -JOIN SalesLT.vProductModelCatalogDescription AS PM -ON P.ProductModelID = PM.ProductModelID -ORDER BY ProductID; - --- Create a table of distinct colors -DECLARE @colors AS TABLE (Color nvarchar(15)); - -INSERT INTO @Colors -SELECT DISTINCT Color FROM SalesLT.Product; - -SELECT ProductID, Name, Color -FROM SalesLT.Product -WHERE Color IN (SELECT Color FROM @Colors); - - --- Retrieve product parent categories from a function -SELECT C.ParentProductCategoryName AS ParentCategory, - C.ProductCategoryName AS Category, - P.ProductID, P.Name AS ProductName -FROM SalesLT.Product AS P -JOIN dbo.ufnGetAllCategories() AS C -ON P.ProductCategoryID = C.ProductCategoryID -ORDER BY ParentCategory, Category, ProductName; - - diff --git a/Mod 07 - Using Table Expressions/Lab Solution/2 - Customer Sales.sql b/Mod 07 - Using Table Expressions/Lab Solution/2 - Customer Sales.sql deleted file mode 100644 index 527fb95..0000000 --- a/Mod 07 - Using Table Expressions/Lab Solution/2 - Customer Sales.sql +++ /dev/null @@ -1,22 +0,0 @@ --- Get sales revenue by company and contact (using derived table) -SELECT CompanyContact, SUM(SalesAmount) AS Revenue -FROM - (SELECT CONCAT(c.CompanyName, CONCAT(' (' + c.FirstName + ' ', c.LastName + ')')), SOH.TotalDue - FROM SalesLT.SalesOrderHeader AS SOH - JOIN SalesLT.Customer AS c - ON SOH.CustomerID = c.CustomerID) AS CustomerSales(CompanyContact, SalesAmount) -GROUP BY CompanyContact -ORDER BY CompanyContact; - --- Get sales revenue by company and contact (using CTE) -WITH CustomerSales(CompanyContact, SalesAmount) -AS -(SELECT CONCAT(c.CompanyName, CONCAT(' (' + c.FirstName + ' ', c.LastName + ')')), SOH.TotalDue - FROM SalesLT.SalesOrderHeader AS SOH - JOIN SalesLT.Customer AS c - ON SOH.CustomerID = c.CustomerID) -SELECT CompanyContact, SUM(SalesAmount) AS Revenue -FROM CustomerSales -GROUP BY CompanyContact -ORDER BY CompanyContact; - diff --git a/Mod 07 - Using Table Expressions/Lab07 - Using Table Expressions.docx b/Mod 07 - Using Table Expressions/Lab07 - Using Table Expressions.docx deleted file mode 100644 index 00e181f..0000000 Binary files a/Mod 07 - Using Table Expressions/Lab07 - Using Table Expressions.docx and /dev/null differ diff --git a/Mod 08 - Grouping Sets and Pivoting Data/Demos/01-Grouping Sets.sql b/Mod 08 - Grouping Sets and Pivoting Data/Demos/01-Grouping Sets.sql deleted file mode 100644 index a5559a8..0000000 --- a/Mod 08 - Grouping Sets and Pivoting Data/Demos/01-Grouping Sets.sql +++ /dev/null @@ -1,9 +0,0 @@ -SELECT cat.ParentProductCategoryName, cat.ProductCategoryName, count(prd.ProductID) AS Products -FROM SalesLT.vGetAllCategories as cat -LEFT JOIN SalesLT.Product AS prd -ON prd.ProductCategoryID = cat.ProductcategoryID -GROUP BY cat.ParentProductCategoryName, cat.ProductCategoryName ---GROUP BY GROUPING SETS(cat.ParentProductCategoryName, cat.ProductCategoryName, ()) ---GROUP BY ROLLUP (cat.ParentProductCategoryName, cat.ProductCategoryName) ---GROUP BY CUBE (cat.ParentProductCategoryName, cat.ProductCategoryName) -ORDER BY cat.ParentProductCategoryName, cat.ProductCategoryName; diff --git a/Mod 08 - Grouping Sets and Pivoting Data/Demos/02-Pivot.sql b/Mod 08 - Grouping Sets and Pivoting Data/Demos/02-Pivot.sql deleted file mode 100644 index ea16674..0000000 --- a/Mod 08 - Grouping Sets and Pivoting Data/Demos/02-Pivot.sql +++ /dev/null @@ -1,62 +0,0 @@ -SELECT * FROM -(SELECT P.ProductID, PC.Name,ISNULL(P.Color, 'Uncolored') AS Color - FROM saleslt.productcategory AS PC - JOIN SalesLT.Product AS P - ON PC.ProductCategoryID=P.ProductCategoryID - ) AS PPC -PIVOT(COUNT(ProductID) FOR Color IN([Red],[Blue],[Black],[Silver],[Yellow],[Grey], [Multi], [Uncolored])) as pvt -ORDER BY Name; - --- Unpivot -CREATE TABLE #ProductColorPivot -(Name varchar(50), Red int, Blue int, Black int, Silver int, Yellow int, Grey int , multi int, uncolored int); - -INSERT INTO #ProductColorPivot -SELECT * FROM -(SELECT P.ProductID, PC.Name,ISNULL(P.Color, 'Uncolored') AS Color - FROM saleslt.productcategory AS PC - JOIN SalesLT.Product AS P - ON PC.ProductCategoryID=P.ProductCategoryID - ) AS PPC -PIVOT(COUNT(ProductID) FOR Color IN([Red],[Blue],[Black],[Silver],[Yellow],[Grey], [Multi], [Uncolored])) as pvt -ORDER BY Name; - -SELECT Name, Color, ProductCount -FROM -(SELECT Name, -[Red],[Blue],[Black],[Silver],[Yellow],[Grey], [Multi], [Uncolored] -FROM #ProductColorPivot) pcp -UNPIVOT -(ProductCount FOR Color IN ([Red],[Blue],[Black],[Silver],[Yellow],[Grey], [Multi], [Uncolored]) -) AS ProductCounts - - - - - - - --- Unpivot -CREATE TABLE #SalesByQuarter -(ProductID int, - Q1 money, - Q2 money, - Q3 money, - Q4 money); - -INSERT INTO #SalesByQuarter -VALUES -(1, 19999.00, 21567.00, 23340.00, 25876.00), -(2, 10997.00, 12465.00, 13367.00, 14365.00), -(3, 21900.00, 21999.00, 23376.00, 23676.00); - -SELECT * FROM #SalesByQuarter; - -SELECT ProductID, Period, Revenue -FROM -(SELECT ProductID, -Q1, Q2, Q3, Q4 -FROM #SalesByQuarter) sbq -UNPIVOT -(Revenue FOR Period IN (Q1, Q2, Q3, Q4) -) AS RevenueReport \ No newline at end of file diff --git a/Mod 08 - Grouping Sets and Pivoting Data/Lab Solutions/01- Regional Sales Totals.sql b/Mod 08 - Grouping Sets and Pivoting Data/Lab Solutions/01- Regional Sales Totals.sql deleted file mode 100644 index cad9c51..0000000 --- a/Mod 08 - Grouping Sets and Pivoting Data/Lab Solutions/01- Regional Sales Totals.sql +++ /dev/null @@ -1,51 +0,0 @@ ---Initial query -SELECT a.CountryRegion, a.StateProvince, SUM(soh.TotalDue) AS Revenue -FROM SalesLT.Address AS a -JOIN SalesLT.CustomerAddress AS ca -ON a.AddressID = ca.AddressID -JOIN SalesLT.Customer AS c -ON ca.CustomerID = c.CustomerID -JOIN SalesLT.SalesOrderHeader as soh -ON c.CustomerID = soh.CustomerID -GROUP BY a.CountryRegion, a.StateProvince -ORDER BY a.CountryRegion, a.StateProvince; - --- With totals -SELECT a.CountryRegion, a.StateProvince, SUM(soh.TotalDue) AS Revenue -FROM SalesLT.Address AS a -JOIN SalesLT.CustomerAddress AS ca -ON a.AddressID = ca.AddressID -JOIN SalesLT.Customer AS c -ON ca.CustomerID = c.CustomerID -JOIN SalesLT.SalesOrderHeader as soh -ON c.CustomerID = soh.CustomerID -GROUP BY ROLLUP(a.CountryRegion, a.StateProvince) -ORDER BY a.CountryRegion, a.StateProvince; - --- Subtotal levels -SELECT a.CountryRegion, a.StateProvince, -IIF(GROUPING_ID(a.CountryRegion) = 1 AND GROUPING_ID(a.StateProvince) = 1, 'Total', IIF(GROUPING_ID(a.StateProvince) = 1, a.CountryRegion + ' Subtotal', a.StateProvince + ' Subtotal')) AS Level, -SUM(soh.TotalDue) AS Revenue -FROM SalesLT.Address AS a -JOIN SalesLT.CustomerAddress AS ca -ON a.AddressID = ca.AddressID -JOIN SalesLT.Customer AS c -ON ca.CustomerID = c.CustomerID -JOIN SalesLT.SalesOrderHeader as soh -ON c.CustomerID = soh.CustomerID -GROUP BY ROLLUP(a.CountryRegion, a.StateProvince) -ORDER BY a.CountryRegion, a.StateProvince; - --- Including cities -SELECT a.CountryRegion, a.StateProvince, a.City, -CHOOSE (1 + GROUPING_ID(a.CountryRegion) + GROUPING_ID(a.StateProvince) + GROUPING_ID(a.City), a.City + ' Subtotal', a.StateProvince + ' Subtotal', a.CountryRegion + ' Subtotal', 'Total') AS Level, -SUM(soh.TotalDue) AS Revenue -FROM SalesLT.Address AS a -JOIN SalesLT.CustomerAddress AS ca -ON a.AddressID = ca.AddressID -JOIN SalesLT.Customer AS c -ON ca.CustomerID = c.CustomerID -JOIN SalesLT.SalesOrderHeader as soh -ON c.CustomerID = soh.CustomerID -GROUP BY ROLLUP(a.CountryRegion, a.StateProvince, a.City) -ORDER BY a.CountryRegion, a.StateProvince, a.City; \ No newline at end of file diff --git a/Mod 08 - Grouping Sets and Pivoting Data/Lab Solutions/02- Customer Sales by Category.sql b/Mod 08 - Grouping Sets and Pivoting Data/Lab Solutions/02- Customer Sales by Category.sql deleted file mode 100644 index a5c270d..0000000 --- a/Mod 08 - Grouping Sets and Pivoting Data/Lab Solutions/02- Customer Sales by Category.sql +++ /dev/null @@ -1,11 +0,0 @@ ---Customer sales by parent category -SELECT * FROM -(SELECT cat.ParentProductCategoryName, cust.CompanyName, sod.LineTotal - FROM SalesLT.SalesOrderDetail AS sod - JOIN SalesLT.SalesOrderHeader AS soh ON sod.SalesOrderID = soh.SalesOrderID - JOIN SalesLT.Customer AS cust ON soh.CustomerID = cust.CustomerID - JOIN SalesLT.Product AS prod ON sod.ProductID = prod.ProductID - JOIN SalesLT.vGetAllCategories AS cat ON prod.ProductcategoryID = cat.ProductCategoryID) AS catsales -PIVOT (SUM(LineTotal) FOR ParentProductCategoryName IN ([Accessories], [Bikes], [Clothing], [Components])) AS pivotedsales -ORDER BY CompanyName; - diff --git a/Mod 08 - Grouping Sets and Pivoting Data/Lab08 - Grouping Sets and Pivoting Data.docx b/Mod 08 - Grouping Sets and Pivoting Data/Lab08 - Grouping Sets and Pivoting Data.docx deleted file mode 100644 index 63cd49d..0000000 Binary files a/Mod 08 - Grouping Sets and Pivoting Data/Lab08 - Grouping Sets and Pivoting Data.docx and /dev/null differ diff --git a/Mod 09 - Modifying Data/Demos/01-Inserting Data.sql b/Mod 09 - Modifying Data/Demos/01-Inserting Data.sql deleted file mode 100644 index 9c2dc6a..0000000 --- a/Mod 09 - Modifying Data/Demos/01-Inserting Data.sql +++ /dev/null @@ -1,68 +0,0 @@ --- Create a table for the demo -CREATE TABLE SalesLT.CallLog -( - CallID int IDENTITY PRIMARY KEY NOT NULL, - CallTime datetime NOT NULL DEFAULT GETDATE(), - SalesPerson nvarchar(256) NOT NULL, - CustomerID int NOT NULL REFERENCES SalesLT.Customer(CustomerID), - PhoneNumber nvarchar(25) NOT NULL, - Notes nvarchar(max) NULL -); -GO - --- Insert a row -INSERT INTO SalesLT.CallLog -VALUES -('2015-01-01T12:30:00', 'adventure-works\pamela0', 1, '245-555-0173', 'Returning call re: enquiry about delivery'); - -SELECT * FROM SalesLT.CallLog; - --- Insert defaults and nulls -INSERT INTO SalesLT.CallLog -VALUES -(DEFAULT, 'adventure-works\david8', 2, '170-555-0127', NULL); - -SELECT * FROM SalesLT.CallLog; - --- Insert a row with explicit columns -INSERT INTO SalesLT.CallLog (SalesPerson, CustomerID, PhoneNumber) -VALUES -('adventure-works\jillian0', 3, '279-555-0130'); - -SELECT * FROM SalesLT.CallLog; - --- Insert multiple rows -INSERT INTO SalesLT.CallLog -VALUES -(DATEADD(mi,-2, GETDATE()), 'adventure-works\jillian0', 4, '710-555-0173', NULL), -(DEFAULT, 'adventure-works\shu0', 5, '828-555-0186', 'Called to arrange deliver of order 10987'); - -SELECT * FROM SalesLT.CallLog; - --- Insert the results of a query -INSERT INTO SalesLT.CallLog (SalesPerson, CustomerID, PhoneNumber, Notes) -SELECT SalesPerson, CustomerID, Phone, 'Sales promotion call' -FROM SalesLT.Customer -WHERE CompanyName = 'Big-Time Bike Store'; - -SELECT * FROM SalesLT.CallLog; - --- Retrieving inserted identity -INSERT INTO SalesLT.CallLog (SalesPerson, CustomerID, PhoneNumber) -VALUES -('adventure-works\josé1', 10, '150-555-0127'); - -SELECT SCOPE_IDENTITY(); - -SELECT * FROM SalesLT.CallLog; - ---Overriding Identity -SET IDENTITY_INSERT SalesLT.CallLog ON; - -INSERT INTO SalesLT.CallLog (CallID, SalesPerson, CustomerID, PhoneNumber) -VALUES -(9, 'adventure-works\josé1', 11, '926-555-0159'); - -SET IDENTITY_INSERT SalesLT.CallLog OFF; - -SELECT * FROM SalesLT.CallLog; \ No newline at end of file diff --git a/Mod 09 - Modifying Data/Demos/02-Updating and Deleting.sql b/Mod 09 - Modifying Data/Demos/02-Updating and Deleting.sql deleted file mode 100644 index 6ca5b7a..0000000 --- a/Mod 09 - Modifying Data/Demos/02-Updating and Deleting.sql +++ /dev/null @@ -1,31 +0,0 @@ --- Update a table -UPDATE SalesLT.CallLog -SET Notes = 'No notes' -WHERE Notes IS NULL; - -SELECT * FROM SalesLT.CallLog; - --- Update multiple columns -UPDATE SalesLT.CallLog -SET SalesPerson = '', PhoneNumber = '' - -SELECT * FROM SalesLT.CallLog; - --- Update from results of a query -UPDATE SalesLT.CallLog -SET SalesPerson = c.SalesPerson, PhoneNumber = c.Phone -FROM SalesLT.Customer AS c -WHERE c.CustomerID = SalesLT.CallLog.CustomerID; - -SELECT * FROM SalesLT.CallLog; - --- Delete rows -DELETE FROM SalesLT.CallLog -WHERE CallTime < DATEADD(dd, -7, GETDATE()); - -SELECT * FROM SalesLT.CallLog; - --- Truncate the table -TRUNCATE TABLE SalesLT.CallLog; - -SELECT * FROM SalesLT.CallLog; \ No newline at end of file diff --git a/Mod 09 - Modifying Data/Lab Solution/01 - Insert Products.sql b/Mod 09 - Modifying Data/Lab Solution/01 - Insert Products.sql deleted file mode 100644 index b4da366..0000000 --- a/Mod 09 - Modifying Data/Lab Solution/01 - Insert Products.sql +++ /dev/null @@ -1,25 +0,0 @@ --- Insert a product -INSERT INTO SalesLT.Product (Name, ProductNumber, StandardCost, ListPrice, ProductCategoryID, SellStartDate) -VALUES -('LED Lights', 'LT-L123', 2.56, 12.99, 37, GETDATE()); - -SELECT SCOPE_IDENTITY(); - -SELECT * FROM SalesLT.Product -WHERE ProductID = SCOPE_IDENTITY(); - --- Insert a new category with two products -INSERT INTO SalesLT.ProductCategory (ParentProductCategoryID, Name) -VALUES -(4, 'Bells and Horns'); - -INSERT INTO SalesLT.Product (Name, ProductNumber, StandardCost, ListPrice, ProductCategoryID, SellStartDate) -VALUES -('Bicycle Bell', 'BB-RING', 2.47, 4.99, IDENT_CURRENT('SalesLT.ProductCategory'), GETDATE()), -('Bicycle Horn', 'BH-PARP', 1.29, 3.75, IDENT_CURRENT('SalesLT.ProductCategory'), GETDATE()); - -SELECT c.Name As Category, p.Name AS Product -FROM SalesLT.Product AS p -JOIN SalesLT.ProductCategory as c ON p.ProductCategoryID = c.ProductCategoryID -WHERE p.ProductCategoryID = IDENT_CURRENT('SalesLT.ProductCategory'); - diff --git a/Mod 09 - Modifying Data/Lab Solution/02 - Update Products.sql b/Mod 09 - Modifying Data/Lab Solution/02 - Update Products.sql deleted file mode 100644 index bf41eec..0000000 --- a/Mod 09 - Modifying Data/Lab Solution/02 - Update Products.sql +++ /dev/null @@ -1,12 +0,0 @@ --- Update product prices -UPDATE SalesLT.Product -SET ListPrice = ListPrice * 1.1 -WHERE ProductCategoryID = - (SELECT ProductCategoryID FROM SalesLT.ProductCategory WHERE Name = 'Bells and Horns'); - --- Discontinue products -UPDATE SalesLT.Product -SET DiscontinuedDate = GETDATE() -WHERE ProductCategoryID = 37 -AND ProductNumber <> 'LT-L123'; - diff --git a/Mod 09 - Modifying Data/Lab Solution/03 - Delete Products.sql b/Mod 09 - Modifying Data/Lab Solution/03 - Delete Products.sql deleted file mode 100644 index f186c07..0000000 --- a/Mod 09 - Modifying Data/Lab Solution/03 - Delete Products.sql +++ /dev/null @@ -1,8 +0,0 @@ --- Delete a product category and its products -DELETE FROM SalesLT.Product -WHERE ProductCategoryID = - (SELECT ProductCategoryID FROM SalesLT.ProductCategory WHERE Name = 'Bells and Horns'); - -DELETE FROM SalesLT.ProductCategory -WHERE ProductCategoryID = - (SELECT ProductCategoryID FROM SalesLT.ProductCategory WHERE Name = 'Bells and Horns'); \ No newline at end of file diff --git a/Mod 09 - Modifying Data/Lab09 - Modifying Data.docx b/Mod 09 - Modifying Data/Lab09 - Modifying Data.docx deleted file mode 100644 index 232b7e8..0000000 Binary files a/Mod 09 - Modifying Data/Lab09 - Modifying Data.docx and /dev/null differ diff --git a/Mod 10 - Programming with Transact-SQL/Demos/0 - Setup.sql b/Mod 10 - Programming with Transact-SQL/Demos/0 - Setup.sql deleted file mode 100644 index 4e9497f..0000000 --- a/Mod 10 - Programming with Transact-SQL/Demos/0 - Setup.sql +++ /dev/null @@ -1,13 +0,0 @@ -IF OBJECT_ID('SalesLT.DemoTable') IS NOT NULL - BEGIN - DROP TABLE SalesLT.DemoTable - END -GO - - -CREATE TABLE SalesLT.DemoTable -(ID INT IDENTITY(1,1), -Description Varchar(20), -CONSTRAINT [PK_DemoTable] PRIMARY KEY CLUSTERED(ID) -) -GO diff --git a/Mod 10 - Programming with Transact-SQL/Demos/1 - Variables.sql b/Mod 10 - Programming with Transact-SQL/Demos/1 - Variables.sql deleted file mode 100644 index 7f2dce2..0000000 --- a/Mod 10 - Programming with Transact-SQL/Demos/1 - Variables.sql +++ /dev/null @@ -1,20 +0,0 @@ ---Search by city using a variable -DECLARE @City VARCHAR(20)='Toronto' -Set @City='Bellevue' - - - -Select FirstName +' '+LastName as [Name],AddressLine1 as Address,City -FROM SalesLT.Customer as C -JOIN SalesLT.CustomerAddress as CA -ON C.CustomerID=CA.CustomerID -JOIN SalesLT.Address as A -ON CA.AddressID=A.AddressID -WHERE City=@City - ---Use a variable as an output -DECLARE @Result money -SELECT @Result=MAX(TotalDue) -FROM SalesLT.SalesOrderHeader - -PRINT @Result \ No newline at end of file diff --git a/Mod 10 - Programming with Transact-SQL/Demos/2 - If Else.sql b/Mod 10 - Programming with Transact-SQL/Demos/2 - If Else.sql deleted file mode 100644 index 674f05d..0000000 --- a/Mod 10 - Programming with Transact-SQL/Demos/2 - If Else.sql +++ /dev/null @@ -1,17 +0,0 @@ ---Simple logical test -If 'Yes'='Yes' -Print 'True' - ---Change code based on a condition -UPDATE SalesLT.Product -SET DiscontinuedDate=getdate() -WHERE ProductID=1; - -IF @@ROWCOUNT<1 -BEGIN - PRINT 'Product was not found' -END -ELSE -BEGIN - PRINT 'Product Updated' -END diff --git a/Mod 10 - Programming with Transact-SQL/Demos/3 - While.sql b/Mod 10 - Programming with Transact-SQL/Demos/3 - While.sql deleted file mode 100644 index 3489cc9..0000000 --- a/Mod 10 - Programming with Transact-SQL/Demos/3 - While.sql +++ /dev/null @@ -1,29 +0,0 @@ -DECLARE @Counter int=1 - -WHILE @Counter <=5 - -BEGIN - INSERT SalesLT.DemoTable(Description) - VALUES ('ROW '+CONVERT(varchar(5),@Counter)) - SET @Counter=@Counter+1 -END - -SELECT Description FROM SalesLT.DemoTable - - ---Testing for existing values -DECLARE @Counter int=1 - -DECLARE @Description int -SELECT @Description=MAX(ID) -FROM SalesLT.DemoTable - -WHILE @Counter <5 -BEGIN - INSERT SalesLT.DemoTable(Description) - VALUES ('ROW '+CONVERT(varchar(5),@Description)) - SET @Description=@Description+1 - SET @Counter=@Counter+1 -END - -SELECT Description FROM SalesLT.DemoTable diff --git a/Mod 10 - Programming with Transact-SQL/Demos/4-Stored Procedure.sql b/Mod 10 - Programming with Transact-SQL/Demos/4-Stored Procedure.sql deleted file mode 100644 index 4fd31ad..0000000 --- a/Mod 10 - Programming with Transact-SQL/Demos/4-Stored Procedure.sql +++ /dev/null @@ -1,17 +0,0 @@ --- Create a stored procedure -CREATE PROCEDURE SalesLT.GetProductsByCategory (@CategoryID INT = NULL) -AS -IF @CategoryID IS NULL - SELECT ProductID, Name, Color, Size, ListPrice - FROM SalesLT.Product -ELSE - SELECT ProductID, Name, Color, Size, ListPrice - FROM SalesLT.Product - WHERE ProductCategoryID = @CategoryID; - - --- Execute the procedure without a parameter -EXEC SalesLT.GetProductsByCategory - --- Execute the procedure with a parameter -EXEC SalesLT.GetProductsByCategory 6 diff --git a/Mod 10 - Programming with Transact-SQL/Lab Solution/01 - Insert Sales Order Script.sql b/Mod 10 - Programming with Transact-SQL/Lab Solution/01 - Insert Sales Order Script.sql deleted file mode 100644 index 6fe48e0..0000000 --- a/Mod 10 - Programming with Transact-SQL/Lab Solution/01 - Insert Sales Order Script.sql +++ /dev/null @@ -1,35 +0,0 @@ --- Insert sales order header -DECLARE @OrderDate datetime = GETDATE(); -DECLARE @DueDate datetime = DATEADD(dd, 7, GETDATE()); -DECLARE @CustomerID int = 1; -DECLARE @OrderID int; - -SET @OrderID = NEXT VALUE FOR SalesLT.SalesOrderNumber; - -INSERT INTO SalesLT.SalesOrderHeader (SalesOrderID, OrderDate, DueDate, CustomerID, ShipMethod) -VALUES -(@OrderID, @OrderDate, @DueDate, @CustomerID, 'CARGO TRANSPORT 5'); - -PRINT @OrderID; - --- Insert sales order details -DECLARE @SalesOrderID int -DECLARE @ProductID int = 760; -DECLARE @Quantity int = 1; -DECLARE @UnitPrice money = 782.99; - -SET @SalesOrderID = 0; -- test with the order ID generated for the sales order header inserted above - -IF EXISTS (SELECT * FROM SalesLT.SalesOrderHeader WHERE SalesOrderID = @SalesOrderID) -BEGIN - INSERT INTO SalesLT.SalesOrderDetail (SalesOrderID, OrderQty, ProductID, UnitPrice) - VALUES - (@SalesOrderID, @Quantity, @ProductID, @UnitPrice) -END -ELSE -BEGIN - PRINT 'The order does not exist' -END - - - diff --git a/Mod 10 - Programming with Transact-SQL/Lab Solution/02 - Update Bike Prices.sql b/Mod 10 - Programming with Transact-SQL/Lab Solution/02 - Update Bike Prices.sql deleted file mode 100644 index dfd9344..0000000 --- a/Mod 10 - Programming with Transact-SQL/Lab Solution/02 - Update Bike Prices.sql +++ /dev/null @@ -1,36 +0,0 @@ -DECLARE @MarketAverage money = 2000; -DECLARE @MarketMax money = 5000; -DECLARE @AWMax money; -DECLARE @AWAverage money; - -SELECT @AWAverage = AVG(ListPrice), @AWMax = MAX(ListPrice) -FROM SalesLT.Product -WHERE ProductCategoryID IN - (SELECT DISTINCT ProductCategoryID - FROM SalesLT.vGetAllCategories - WHERE ParentProductCategoryName = 'Bikes'); - -WHILE @AWAverage < @MarketAverage -BEGIN - UPDATE SalesLT.Product - SET ListPrice = ListPrice * 1.1 - WHERE ProductCategoryID IN - (SELECT DISTINCT ProductCategoryID - FROM SalesLT.vGetAllCategories - WHERE ParentProductCategoryName = 'Bikes'); - - SELECT @AWAverage = AVG(ListPrice), @AWMax = MAX(ListPrice) - FROM SalesLT.Product - WHERE ProductCategoryID IN - (SELECT DISTINCT ProductCategoryID - FROM SalesLT.vGetAllCategories - WHERE ParentProductCategoryName = 'Bikes'); - - IF @AWMax >= @MarketMax - BREAK - ELSE - CONTINUE -END -PRINT 'New average bike price:' + CONVERT(varchar, @AWAverage); -PRINT 'New maximum bike price:' + CONVERT(varchar, @AWMax); - diff --git a/Mod 10 - Programming with Transact-SQL/Lab10 - Programming with Transact-SQL.docx b/Mod 10 - Programming with Transact-SQL/Lab10 - Programming with Transact-SQL.docx deleted file mode 100644 index 79be970..0000000 Binary files a/Mod 10 - Programming with Transact-SQL/Lab10 - Programming with Transact-SQL.docx and /dev/null differ diff --git a/Mod 11 - Error Handling and Transactions/Demos/01-Raising Errors.sql b/Mod 11 - Error Handling and Transactions/Demos/01-Raising Errors.sql deleted file mode 100644 index 2e116fd..0000000 --- a/Mod 11 - Error Handling and Transactions/Demos/01-Raising Errors.sql +++ /dev/null @@ -1,28 +0,0 @@ --- View a system error -INSERT INTO SalesLT.SalesOrderDetail (SalesOrderID, OrderQty, ProductID, UnitPrice, UnitPriceDiscount) -VALUES -(100000, 1, 680, 1431.50, 0.00); - - - - - --- Raise an error with RAISERROR -UPDATE SalesLT.Product -SET DiscontinuedDate = GETDATE() -WHERE ProductID = 0; - -IF @@ROWCOUNT < 1 - RAISERROR('The product was not found - no products have been updated', 16, 0); - - - - - --- Raise an error with THROW -UPDATE SalesLT.Product -SET DiscontinuedDate = GETDATE() -WHERE ProductID = 0; - -IF @@ROWCOUNT < 1 - THROW 50001, 'The product was not found - no products have been updated', 0; \ No newline at end of file diff --git a/Mod 11 - Error Handling and Transactions/Demos/02-Handling Errors.sql b/Mod 11 - Error Handling and Transactions/Demos/02-Handling Errors.sql deleted file mode 100644 index 1d7b246..0000000 --- a/Mod 11 - Error Handling and Transactions/Demos/02-Handling Errors.sql +++ /dev/null @@ -1,37 +0,0 @@ --- catch an error -BEGIN TRY - UPDATE SalesLT.Product - SET ProductNumber = ProductID / ISNULL(Weight, 0); -END TRY -BEGIN CATCH - PRINT 'The following error occurred:'; - PRINT ERROR_MESSAGE(); -END CATCH; - --- Catch and rethrow -BEGIN TRY - UPDATE SalesLT.Product - SET ProductNumber = ProductID / ISNULL(Weight, 0); -END TRY -BEGIN CATCH - PRINT 'The following error occurred:'; - PRINT ERROR_MESSAGE(); - THROW; -END CATCH; - --- Catch, log, and throw a custom error -BEGIN TRY - UPDATE SalesLT.Product - SET ProductNumber = ProductID / ISNULL(Weight, 0); -END TRY -BEGIN CATCH - DECLARE @ErrorLogID as int, @ErrorMsg AS varchar(250); - EXECUTE dbo.uspLogError @ErrorLogID OUTPUT; - SET @ErrorMsg = 'The update failed because of an error. View error #' - + CAST(@ErrorLogID AS varchar) - + ' in the error log for details.'; - THROW 50001, @ErrorMsg, 0; -END CATCH; - --- View the error log -SELECT * FROM dbo.ErrorLog; \ No newline at end of file diff --git a/Mod 11 - Error Handling and Transactions/Demos/03-Transactions.sql b/Mod 11 - Error Handling and Transactions/Demos/03-Transactions.sql deleted file mode 100644 index c8eb505..0000000 --- a/Mod 11 - Error Handling and Transactions/Demos/03-Transactions.sql +++ /dev/null @@ -1,85 +0,0 @@ --- No transaction -BEGIN TRY - INSERT INTO SalesLT.SalesOrderHeader (DueDate, CustomerID, ShipMethod) - VALUES - (DATEADD(dd, 7, GETDATE()), 1, 'STD DELIVERY'); - - DECLARE @SalesOrderID int = SCOPE_IDENTITY(); - - INSERT INTO SalesLT.SalesOrderDetail (SalesOrderID, OrderQty, ProductID, UnitPrice, UnitPriceDiscount) - VALUES - (@SalesOrderID, 1, 99999, 1431.50, 0.00); -END TRY -BEGIN CATCH - PRINT ERROR_MESSAGE(); -END CATCH; - --- View orphaned orders -SELECT h.SalesOrderID, h.DueDate, h.CustomerID, h.ShipMethod, d.SalesOrderDetailID -FROM SalesLT.SalesOrderHeader AS h -LEFT JOIN SalesLT.SalesOrderDetail AS d -ON d.SalesOrderID = h.SalesOrderID -WHERE D.SalesOrderDetailID IS NULL; - --- Manually delete orphaned record -DELETE FROM SalesLT.SalesOrderHeader -WHERE SalesOrderID = SCOPE_IDENTITY(); - --- Use a transaction -BEGIN TRY - BEGIN TRANSACTION - INSERT INTO SalesLT.SalesOrderHeader (DueDate, CustomerID, ShipMethod) - VALUES - (DATEADD(dd, 7, GETDATE()), 1, 'STD DELIVERY'); - - DECLARE @SalesOrderID int = SCOPE_IDENTITY(); - - INSERT INTO SalesLT.SalesOrderDetail (SalesOrderID, OrderQty, ProductID, UnitPrice, UnitPriceDiscount) - VALUES - (@SalesOrderID, 1, 99999, 1431.50, 0.00); - COMMIT TRANSACTION -END TRY -BEGIN CATCH - IF @@TRANCOUNT > 0 - BEGIN - PRINT XACT_STATE(); - ROLLBACK TRANSACTION; - END - PRINT ERROR_MESSAGE(); - THROW 50001,'An insert failed. The transaction was cancelled.', 0; -END CATCH; - --- Check for orphaned orders -SELECT h.SalesOrderID, h.DueDate, h.CustomerID, h.ShipMethod, d.SalesOrderDetailID -FROM SalesLT.SalesOrderHeader AS h -LEFT JOIN SalesLT.SalesOrderDetail AS d -ON d.SalesOrderID = h.SalesOrderID -WHERE D.SalesOrderDetailID IS NULL - --- Use XACT_ABORT -SET XACT_ABORT ON; -BEGIN TRY - BEGIN TRANSACTION - INSERT INTO SalesLT.SalesOrderHeader (DueDate, CustomerID, ShipMethod) - VALUES - (DATEADD(dd, 7, GETDATE()), 1, 'STD DELIVERY'); - - DECLARE @SalesOrderID int = SCOPE_IDENTITY(); - - INSERT INTO SalesLT.SalesOrderDetail (SalesOrderID, OrderQty, ProductID, UnitPrice, UnitPriceDiscount) - VALUES - (@SalesOrderID, 1, 99999, 1431.50, 0.00); - COMMIT TRANSACTION -END TRY -BEGIN CATCH - PRINT ERROR_MESSAGE(); - THROW 50001,'An insert failed. The transaction was cancelled.', 0; -END CATCH; -SET XACT_ABORT OFF; - --- Check for orphaned orders -SELECT h.SalesOrderID, h.DueDate, h.CustomerID, h.ShipMethod, d.SalesOrderDetailID -FROM SalesLT.SalesOrderHeader AS h -LEFT JOIN SalesLT.SalesOrderDetail AS d -ON d.SalesOrderID = h.SalesOrderID -WHERE D.SalesOrderDetailID IS NULL \ No newline at end of file diff --git a/Mod 11 - Error Handling and Transactions/Lab Solution/01-Logging Errors.sql b/Mod 11 - Error Handling and Transactions/Lab Solution/01-Logging Errors.sql deleted file mode 100644 index 74a4c96..0000000 --- a/Mod 11 - Error Handling and Transactions/Lab Solution/01-Logging Errors.sql +++ /dev/null @@ -1,29 +0,0 @@ - -DECLARE @SalesOrderID int = 0 - --- uncomment the following line to delete an existing record --- SELECT @SalesOrderID = MIN(SalesOrderID) FROM SalesLT.SalesOrderHeader; - -BEGIN TRY - IF NOT EXISTS (SELECT * FROM SalesLT.SalesOrderHeader - WHERE SalesOrderID = @SalesOrderID) - BEGIN - -- Throw a custom error if the specified order doesn't exist - DECLARE @error varchar(25); - SET @error = 'Order #' + cast(@SalesOrderID as varchar) + ' does not exist'; - THROW 50001, @error, 0 - END - ELSE - BEGIN - DELETE FROM SalesLT.SalesOrderDetail - WHERE SalesOrderID = @SalesOrderID; - - DELETE FROM SalesLT.SalesOrderHeader - WHERE SalesOrderID = @SalesOrderID; - END -END TRY -BEGIN CATCH - -- Catch and print the error - PRINT ERROR_MESSAGE(); -END CATCH - diff --git a/Mod 11 - Error Handling and Transactions/Lab Solution/02-Ensuring Data Consistency.sql b/Mod 11 - Error Handling and Transactions/Lab Solution/02-Ensuring Data Consistency.sql deleted file mode 100644 index 2907a6f..0000000 --- a/Mod 11 - Error Handling and Transactions/Lab Solution/02-Ensuring Data Consistency.sql +++ /dev/null @@ -1,42 +0,0 @@ - -DECLARE @SalesOrderID int = 0 - --- uncomment the following line to specify an existing order --- SELECT @SalesOrderID = MIN(SalesOrderID) FROM SalesLT.SalesOrderHeader; - -BEGIN TRY - IF NOT EXISTS (SELECT * FROM SalesLT.SalesOrderHeader - WHERE SalesOrderID = @SalesOrderID) - BEGIN - -- Throw a custom error if the specified order doesn't exist - DECLARE @error varchar(25); - SET @error = 'Order #' + cast(@SalesOrderID as varchar) + ' does not exist'; - THROW 50001, @error, 0 - END - ELSE - BEGIN - BEGIN TRANSACTION - DELETE FROM SalesLT.SalesOrderDetail - WHERE SalesOrderID = @SalesOrderID; - - -- THROW 50001, 'Unexpected error', 0 --Uncomment to test transaction - - DELETE FROM SalesLT.SalesOrderHeader - WHERE SalesOrderID = @SalesOrderID; - COMMIT TRANSACTION - END -END TRY -BEGIN CATCH - IF @@TRANCOUNT > 0 - BEGIN - -- Rollback the transaction and re-throw the error - ROLLBACK TRANSACTION; - THROW; - END - ELSE - BEGIN - -- Report the error - PRINT ERROR_MESSAGE(); - END -END CATCH - diff --git a/Mod 11 - Error Handling and Transactions/Lab11 - Error Handling and Transactions.docx b/Mod 11 - Error Handling and Transactions/Lab11 - Error Handling and Transactions.docx deleted file mode 100644 index abb484c..0000000 Binary files a/Mod 11 - Error Handling and Transactions/Lab11 - Error Handling and Transactions.docx and /dev/null differ diff --git a/README.md b/README.md index 618b5d2..49d5acf 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,8 @@ -# QueryingT-SQL -Demo and lab files for Querying with T-SQL course +![Querying with Transact-SQL] +(https://www.edx.org/sites/default/files/styles/course_video_banner/public/course/image/featured-card/dat201x_thumbnail.jpg) + +*** + +This repository contains the lab files and handouts for the Microsoft course *Querying with Transact-SQL*. Sign up for this free course on [edX](https://www.edx.org/course/querying-transact-sql-microsoft-dat201x-0) or [Microsoft Virtual Academy](https://mva.microsoft.com/en-US/training-courses/querying-with-transact-sql-10530). + +If you are completing the course on Microsoft Virtual Academy (MVA), follow the instructions in the MVA Setup Guide to prepare for the labs. If you are completing the course in edX, follow the instructions in the Getting Started with DAT201x document. diff --git a/Slides/Querying_with_T-SQL_-_01.pptx b/Slides/Querying_with_T-SQL_-_01.pptx new file mode 100644 index 0000000..93623a6 Binary files /dev/null and b/Slides/Querying_with_T-SQL_-_01.pptx differ diff --git a/Slides/Querying_with_T-SQL_-_02.pptx b/Slides/Querying_with_T-SQL_-_02.pptx new file mode 100644 index 0000000..3458bb8 Binary files /dev/null and b/Slides/Querying_with_T-SQL_-_02.pptx differ diff --git a/Slides/Querying_with_T-SQL_-_03.pptx b/Slides/Querying_with_T-SQL_-_03.pptx new file mode 100644 index 0000000..a8ff3e3 Binary files /dev/null and b/Slides/Querying_with_T-SQL_-_03.pptx differ diff --git a/Slides/Querying_with_T-SQL_-_04.pptx b/Slides/Querying_with_T-SQL_-_04.pptx new file mode 100644 index 0000000..8ea6e0e Binary files /dev/null and b/Slides/Querying_with_T-SQL_-_04.pptx differ diff --git a/Slides/Querying_with_T-SQL_-_05.pptx b/Slides/Querying_with_T-SQL_-_05.pptx new file mode 100644 index 0000000..08aab55 Binary files /dev/null and b/Slides/Querying_with_T-SQL_-_05.pptx differ diff --git a/Slides/Querying_with_T-SQL_-_06.pptx b/Slides/Querying_with_T-SQL_-_06.pptx new file mode 100644 index 0000000..0033c58 Binary files /dev/null and b/Slides/Querying_with_T-SQL_-_06.pptx differ diff --git a/Slides/Querying_with_T-SQL_-_07.pptx b/Slides/Querying_with_T-SQL_-_07.pptx new file mode 100644 index 0000000..9cd0213 Binary files /dev/null and b/Slides/Querying_with_T-SQL_-_07.pptx differ diff --git a/Slides/Querying_with_T-SQL_-_08.pptx b/Slides/Querying_with_T-SQL_-_08.pptx new file mode 100644 index 0000000..270da36 Binary files /dev/null and b/Slides/Querying_with_T-SQL_-_08.pptx differ diff --git a/Slides/Querying_with_T-SQL_-_09.pptx b/Slides/Querying_with_T-SQL_-_09.pptx new file mode 100644 index 0000000..3a52b51 Binary files /dev/null and b/Slides/Querying_with_T-SQL_-_09.pptx differ diff --git a/Slides/Querying_with_T-SQL_-_10.pptx b/Slides/Querying_with_T-SQL_-_10.pptx new file mode 100644 index 0000000..dd2c6c4 Binary files /dev/null and b/Slides/Querying_with_T-SQL_-_10.pptx differ diff --git a/Slides/Querying_with_T-SQL_-_11.pptx b/Slides/Querying_with_T-SQL_-_11.pptx new file mode 100644 index 0000000..e48497e Binary files /dev/null and b/Slides/Querying_with_T-SQL_-_11.pptx differ diff --git a/Syllabus.pdf b/Syllabus.pdf new file mode 100644 index 0000000..c6e41fe Binary files /dev/null and b/Syllabus.pdf differ diff --git a/adventureworkslt.sql b/adventureworkslt.sql new file mode 100644 index 0000000..dc31b4b Binary files /dev/null and b/adventureworkslt.sql differ