├── Chapter01 ├── Create Backorder View.sql ├── Create Order view.sql ├── Fact Order Record Counts with Backorder.sql ├── Fact Order Record Counts.sql ├── Fig 1.1 Fact Order table details.sql ├── Fig 1.2 Fact Order table records.sql ├── Fig 1.3Fact Order Initial Result set.sql ├── Fig 1.4 Fact Order Result set w order year and month.sql ├── Fig 1.5 Fact Order result set using a view.sql ├── Fig 1.6 Back Order aggregation.sql ├── Fig 1.6 Backorder Aggregation with a view.sql ├── Fig 1.7 Result set using sub queries.sql ├── Fig 1.8 Result Set using two views.sql └── System table query.sql ├── Chapter02 ├── Fig 2.1 Sample Aggregation.sql ├── Fig 2.10 Aggregation using MIN.sql ├── Fig 2.11 Aggregation using subqueries.sql ├── Fig 2.12 Aggregation using JOIN.sql ├── Fig 2.3 Aggregation by Invoice Year.sql ├── Fig 2.4 Aggregation with delivery date added.sql ├── Fig 2.6 Aggregation using AVG.sql ├── Fig 2.7 Aggregaion using SUM.sql ├── Fig 2.8 Aggregation using COUNT.sql └── Fig 2.9 Aggregation using MAX.sql ├── Chapter03 ├── Fig 3.1 Query.sql ├── Fig 3.10 Query.sql ├── Fig 3.11 Query.sql ├── Fig 3.12 Query.sql ├── Fig 3.13 Query.sql ├── Fig 3.14 Query.sql ├── Fig 3.15 Query.sql ├── Fig 3.16 Query.sql ├── Fig 3.17 Query.sql ├── Fig 3.18 Query.sql ├── Fig 3.19 Query.sql ├── Fig 3.2 Query.sql ├── Fig 3.20 Query.sql ├── Fig 3.21 Query.sql ├── Fig 3.22 Query.sql ├── Fig 3.3 Query.sql ├── Fig 3.4 Query.sql ├── Fig 3.5 Query.sql ├── Fig 3.6 Query.sql ├── Fig 3.7 Query.sql ├── Fig 3.8 Query.sql └── Fig 3.9 Query.sql ├── Chapter04 ├── Fig 4.1 Query.sql ├── Fig 4.10 Query.sql ├── Fig 4.11 Query.sql ├── Fig 4.12 Query.sql ├── Fig 4.13 Query.sql ├── Fig 4.14 Query.sql ├── Fig 4.15 Query.sql ├── Fig 4.16 Query.sql ├── Fig 4.17 Query.sql ├── Fig 4.2 Query.sql ├── Fig 4.3 Query.sql ├── Fig 4.4 Query.sql ├── Fig 4.5 Query.sql ├── Fig 4.6 Query.sql ├── Fig 4.6 Reset Query.sql ├── Fig 4.6 Update Query.sql ├── Fig 4.8 Query.sql └── Fig 4.9 Query.sql ├── Chapter05 ├── Figure 5.1 ISO Date.sql ├── Figure 5.3 ISO Date with Sales.sql ├── Figure 5.5 Synapse Recursive.sql ├── Figure 5.5 part 1 Create Employee Table.sql └── Figure 5.5 part 2 Recursive Heirarchy.sql ├── Chapter06 ├── Figure 6.1 RowNumber InvoiceID ├── Figure 6.10 First and Last Value ├── Figure 6.11 YoY Changes ├── Figure 6.2 RowNumber CustomerID ├── Figure 6.3 RowNumber CustomerID InvoiceID ├── Figure 6.4 RowNumber ParitionBy CustomerID ├── Figure 6.5 Aggregate Window Functions ├── Figure 6.6 LAG Days Between Orders ├── Figure 6.7 LAG Finding a Pattern ├── Figure 6.8 First n Records in Group └── Figure 6.9 Three month count and average ├── Chapter07 └── Chapter 7 - Reshaping Data with Advanced Techniques.sql ├── Chapter08 └── Fig 8.1 Sample query for Chapter 8.sql ├── Chapter09 └── Chapter 9 - Understanding Query Plans.sql ├── Chapter10 └── Chapter 10 - Understanding the Impact of Indexes on Query Design.sql ├── Chapter11 ├── Create CustomerOrders Table.sql ├── ISJSON example.sql ├── JSON OBJECT example.sql ├── JSON _ARRAY example.sql ├── JSON _OBJECT example 2.sql ├── JSON _PATH _EXISTS examples.sql ├── JSON _QUERY examples.sql ├── JSON _VALUE example.sql ├── JSON path with root.sql ├── JSON path.sql ├── JSON tabular results in a view.sql ├── JSON tabular results.sql ├── JSON_MODIFY example.sql ├── Select Orders Auto With Join.sql ├── Select Orders Auto.sql ├── Select Orders Path For Table Insert.sql ├── Select Orders Path.sql └── insert records into customer orders.sql ├── Chapter12 ├── OPENROWSET and External Tables Scripts.sql ├── PurchaseOrders.csv └── Suppliers.csv ├── Chapter13 └── Notebooks │ └── My Analytics │ ├── AnalyzingCustomers.ipynb │ ├── Notebook-1.ipynb │ ├── README.md │ ├── _config.yml │ └── _toc.yml ├── LICENSE ├── OldChapter10 └── OldChapter10 - Understanding Query Hints.sql └── README.md /Chapter01/Create Backorder View.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter01/Create Backorder View.sql -------------------------------------------------------------------------------- /Chapter01/Create Order view.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter01/Create Order view.sql -------------------------------------------------------------------------------- /Chapter01/Fact Order Record Counts with Backorder.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter01/Fact Order Record Counts with Backorder.sql -------------------------------------------------------------------------------- /Chapter01/Fact Order Record Counts.sql: -------------------------------------------------------------------------------- 1 | SELECT count(*) 2 | FROM [WideWorldImportersDW].[Fact].[Order] 3 | -------------------------------------------------------------------------------- /Chapter01/Fig 1.1 Fact Order table details.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter01/Fig 1.1 Fact Order table details.sql -------------------------------------------------------------------------------- /Chapter01/Fig 1.2 Fact Order table records.sql: -------------------------------------------------------------------------------- 1 | SELECT TOP (1000) * 2 | FROM [WideWorldImportersDW].[Fact].[Order]; 3 | -------------------------------------------------------------------------------- /Chapter01/Fig 1.3Fact Order Initial Result set.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter01/Fig 1.3Fact Order Initial Result set.sql -------------------------------------------------------------------------------- /Chapter01/Fig 1.4 Fact Order Result set w order year and month.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter01/Fig 1.4 Fact Order Result set w order year and month.sql -------------------------------------------------------------------------------- /Chapter01/Fig 1.5 Fact Order result set using a view.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter01/Fig 1.5 Fact Order result set using a view.sql -------------------------------------------------------------------------------- /Chapter01/Fig 1.6 Back Order aggregation.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter01/Fig 1.6 Back Order aggregation.sql -------------------------------------------------------------------------------- /Chapter01/Fig 1.6 Backorder Aggregation with a view.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter01/Fig 1.6 Backorder Aggregation with a view.sql -------------------------------------------------------------------------------- /Chapter01/Fig 1.7 Result set using sub queries.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter01/Fig 1.7 Result set using sub queries.sql -------------------------------------------------------------------------------- /Chapter01/Fig 1.8 Result Set using two views.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter01/Fig 1.8 Result Set using two views.sql -------------------------------------------------------------------------------- /Chapter01/System table query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter01/System table query.sql -------------------------------------------------------------------------------- /Chapter02/Fig 2.1 Sample Aggregation.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter02/Fig 2.1 Sample Aggregation.sql -------------------------------------------------------------------------------- /Chapter02/Fig 2.10 Aggregation using MIN.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter02/Fig 2.10 Aggregation using MIN.sql -------------------------------------------------------------------------------- /Chapter02/Fig 2.11 Aggregation using subqueries.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter02/Fig 2.11 Aggregation using subqueries.sql -------------------------------------------------------------------------------- /Chapter02/Fig 2.12 Aggregation using JOIN.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter02/Fig 2.12 Aggregation using JOIN.sql -------------------------------------------------------------------------------- /Chapter02/Fig 2.3 Aggregation by Invoice Year.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter02/Fig 2.3 Aggregation by Invoice Year.sql -------------------------------------------------------------------------------- /Chapter02/Fig 2.4 Aggregation with delivery date added.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter02/Fig 2.4 Aggregation with delivery date added.sql -------------------------------------------------------------------------------- /Chapter02/Fig 2.6 Aggregation using AVG.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter02/Fig 2.6 Aggregation using AVG.sql -------------------------------------------------------------------------------- /Chapter02/Fig 2.7 Aggregaion using SUM.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter02/Fig 2.7 Aggregaion using SUM.sql -------------------------------------------------------------------------------- /Chapter02/Fig 2.8 Aggregation using COUNT.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter02/Fig 2.8 Aggregation using COUNT.sql -------------------------------------------------------------------------------- /Chapter02/Fig 2.9 Aggregation using MAX.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter02/Fig 2.9 Aggregation using MAX.sql -------------------------------------------------------------------------------- /Chapter03/Fig 3.1 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter03/Fig 3.1 Query.sql -------------------------------------------------------------------------------- /Chapter03/Fig 3.10 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter03/Fig 3.10 Query.sql -------------------------------------------------------------------------------- /Chapter03/Fig 3.11 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter03/Fig 3.11 Query.sql -------------------------------------------------------------------------------- /Chapter03/Fig 3.12 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter03/Fig 3.12 Query.sql -------------------------------------------------------------------------------- /Chapter03/Fig 3.13 Query.sql: -------------------------------------------------------------------------------- 1 | SELECT CONVERT(DECIMAL(10,2), 102.55268) AS Number -------------------------------------------------------------------------------- /Chapter03/Fig 3.14 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter03/Fig 3.14 Query.sql -------------------------------------------------------------------------------- /Chapter03/Fig 3.15 Query.sql: -------------------------------------------------------------------------------- 1 | SELECT '$'+ CONVERT(nvarchar(10), 102.55268) AS Number -------------------------------------------------------------------------------- /Chapter03/Fig 3.16 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter03/Fig 3.16 Query.sql -------------------------------------------------------------------------------- /Chapter03/Fig 3.17 Query.sql: -------------------------------------------------------------------------------- 1 | SELECT ROUND(102.55268, 1) AS Number -------------------------------------------------------------------------------- /Chapter03/Fig 3.18 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter03/Fig 3.18 Query.sql -------------------------------------------------------------------------------- /Chapter03/Fig 3.19 Query.sql: -------------------------------------------------------------------------------- 1 | SELECT FLOOR(102.55268) AS Number -------------------------------------------------------------------------------- /Chapter03/Fig 3.2 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter03/Fig 3.2 Query.sql -------------------------------------------------------------------------------- /Chapter03/Fig 3.20 Query.sql: -------------------------------------------------------------------------------- 1 | SELECT CEILING(-102.55268) AS Number -------------------------------------------------------------------------------- /Chapter03/Fig 3.21 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter03/Fig 3.21 Query.sql -------------------------------------------------------------------------------- /Chapter03/Fig 3.22 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter03/Fig 3.22 Query.sql -------------------------------------------------------------------------------- /Chapter03/Fig 3.3 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter03/Fig 3.3 Query.sql -------------------------------------------------------------------------------- /Chapter03/Fig 3.4 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter03/Fig 3.4 Query.sql -------------------------------------------------------------------------------- /Chapter03/Fig 3.5 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter03/Fig 3.5 Query.sql -------------------------------------------------------------------------------- /Chapter03/Fig 3.6 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter03/Fig 3.6 Query.sql -------------------------------------------------------------------------------- /Chapter03/Fig 3.7 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter03/Fig 3.7 Query.sql -------------------------------------------------------------------------------- /Chapter03/Fig 3.8 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter03/Fig 3.8 Query.sql -------------------------------------------------------------------------------- /Chapter03/Fig 3.9 Query.sql: -------------------------------------------------------------------------------- 1 | SELECT FORMAT(0.15,'#0.0%') [Tax] -------------------------------------------------------------------------------- /Chapter04/Fig 4.1 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter04/Fig 4.1 Query.sql -------------------------------------------------------------------------------- /Chapter04/Fig 4.10 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter04/Fig 4.10 Query.sql -------------------------------------------------------------------------------- /Chapter04/Fig 4.11 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter04/Fig 4.11 Query.sql -------------------------------------------------------------------------------- /Chapter04/Fig 4.12 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter04/Fig 4.12 Query.sql -------------------------------------------------------------------------------- /Chapter04/Fig 4.13 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter04/Fig 4.13 Query.sql -------------------------------------------------------------------------------- /Chapter04/Fig 4.14 Query.sql: -------------------------------------------------------------------------------- 1 | SELECT ISNULL('Hello', 'World') AS [Output] -------------------------------------------------------------------------------- /Chapter04/Fig 4.15 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter04/Fig 4.15 Query.sql -------------------------------------------------------------------------------- /Chapter04/Fig 4.16 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter04/Fig 4.16 Query.sql -------------------------------------------------------------------------------- /Chapter04/Fig 4.17 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter04/Fig 4.17 Query.sql -------------------------------------------------------------------------------- /Chapter04/Fig 4.2 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter04/Fig 4.2 Query.sql -------------------------------------------------------------------------------- /Chapter04/Fig 4.3 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter04/Fig 4.3 Query.sql -------------------------------------------------------------------------------- /Chapter04/Fig 4.4 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter04/Fig 4.4 Query.sql -------------------------------------------------------------------------------- /Chapter04/Fig 4.5 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter04/Fig 4.5 Query.sql -------------------------------------------------------------------------------- /Chapter04/Fig 4.6 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter04/Fig 4.6 Query.sql -------------------------------------------------------------------------------- /Chapter04/Fig 4.6 Reset Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter04/Fig 4.6 Reset Query.sql -------------------------------------------------------------------------------- /Chapter04/Fig 4.6 Update Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter04/Fig 4.6 Update Query.sql -------------------------------------------------------------------------------- /Chapter04/Fig 4.8 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter04/Fig 4.8 Query.sql -------------------------------------------------------------------------------- /Chapter04/Fig 4.9 Query.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter04/Fig 4.9 Query.sql -------------------------------------------------------------------------------- /Chapter05/Figure 5.1 ISO Date.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter05/Figure 5.1 ISO Date.sql -------------------------------------------------------------------------------- /Chapter05/Figure 5.3 ISO Date with Sales.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter05/Figure 5.3 ISO Date with Sales.sql -------------------------------------------------------------------------------- /Chapter05/Figure 5.5 Synapse Recursive.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter05/Figure 5.5 Synapse Recursive.sql -------------------------------------------------------------------------------- /Chapter05/Figure 5.5 part 1 Create Employee Table.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter05/Figure 5.5 part 1 Create Employee Table.sql -------------------------------------------------------------------------------- /Chapter05/Figure 5.5 part 2 Recursive Heirarchy.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter05/Figure 5.5 part 2 Recursive Heirarchy.sql -------------------------------------------------------------------------------- /Chapter06/Figure 6.1 RowNumber InvoiceID: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter06/Figure 6.1 RowNumber InvoiceID -------------------------------------------------------------------------------- /Chapter06/Figure 6.10 First and Last Value: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter06/Figure 6.10 First and Last Value -------------------------------------------------------------------------------- /Chapter06/Figure 6.11 YoY Changes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter06/Figure 6.11 YoY Changes -------------------------------------------------------------------------------- /Chapter06/Figure 6.2 RowNumber CustomerID: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter06/Figure 6.2 RowNumber CustomerID -------------------------------------------------------------------------------- /Chapter06/Figure 6.3 RowNumber CustomerID InvoiceID: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter06/Figure 6.3 RowNumber CustomerID InvoiceID -------------------------------------------------------------------------------- /Chapter06/Figure 6.4 RowNumber ParitionBy CustomerID: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter06/Figure 6.4 RowNumber ParitionBy CustomerID -------------------------------------------------------------------------------- /Chapter06/Figure 6.5 Aggregate Window Functions: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter06/Figure 6.5 Aggregate Window Functions -------------------------------------------------------------------------------- /Chapter06/Figure 6.6 LAG Days Between Orders: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter06/Figure 6.6 LAG Days Between Orders -------------------------------------------------------------------------------- /Chapter06/Figure 6.7 LAG Finding a Pattern: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter06/Figure 6.7 LAG Finding a Pattern -------------------------------------------------------------------------------- /Chapter06/Figure 6.8 First n Records in Group: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter06/Figure 6.8 First n Records in Group -------------------------------------------------------------------------------- /Chapter06/Figure 6.9 Three month count and average: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter06/Figure 6.9 Three month count and average -------------------------------------------------------------------------------- /Chapter07/Chapter 7 - Reshaping Data with Advanced Techniques.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter07/Chapter 7 - Reshaping Data with Advanced Techniques.sql -------------------------------------------------------------------------------- /Chapter08/Fig 8.1 Sample query for Chapter 8.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter08/Fig 8.1 Sample query for Chapter 8.sql -------------------------------------------------------------------------------- /Chapter09/Chapter 9 - Understanding Query Plans.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter09/Chapter 9 - Understanding Query Plans.sql -------------------------------------------------------------------------------- /Chapter10/Chapter 10 - Understanding the Impact of Indexes on Query Design.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter10/Chapter 10 - Understanding the Impact of Indexes on Query Design.sql -------------------------------------------------------------------------------- /Chapter11/Create CustomerOrders Table.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter11/Create CustomerOrders Table.sql -------------------------------------------------------------------------------- /Chapter11/ISJSON example.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter11/ISJSON example.sql -------------------------------------------------------------------------------- /Chapter11/JSON OBJECT example.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter11/JSON OBJECT example.sql -------------------------------------------------------------------------------- /Chapter11/JSON _ARRAY example.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter11/JSON _ARRAY example.sql -------------------------------------------------------------------------------- /Chapter11/JSON _OBJECT example 2.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter11/JSON _OBJECT example 2.sql -------------------------------------------------------------------------------- /Chapter11/JSON _PATH _EXISTS examples.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter11/JSON _PATH _EXISTS examples.sql -------------------------------------------------------------------------------- /Chapter11/JSON _QUERY examples.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter11/JSON _QUERY examples.sql -------------------------------------------------------------------------------- /Chapter11/JSON _VALUE example.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter11/JSON _VALUE example.sql -------------------------------------------------------------------------------- /Chapter11/JSON path with root.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter11/JSON path with root.sql -------------------------------------------------------------------------------- /Chapter11/JSON path.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter11/JSON path.sql -------------------------------------------------------------------------------- /Chapter11/JSON tabular results in a view.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter11/JSON tabular results in a view.sql -------------------------------------------------------------------------------- /Chapter11/JSON tabular results.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter11/JSON tabular results.sql -------------------------------------------------------------------------------- /Chapter11/JSON_MODIFY example.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter11/JSON_MODIFY example.sql -------------------------------------------------------------------------------- /Chapter11/Select Orders Auto With Join.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter11/Select Orders Auto With Join.sql -------------------------------------------------------------------------------- /Chapter11/Select Orders Auto.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter11/Select Orders Auto.sql -------------------------------------------------------------------------------- /Chapter11/Select Orders Path For Table Insert.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter11/Select Orders Path For Table Insert.sql -------------------------------------------------------------------------------- /Chapter11/Select Orders Path.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter11/Select Orders Path.sql -------------------------------------------------------------------------------- /Chapter11/insert records into customer orders.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter11/insert records into customer orders.sql -------------------------------------------------------------------------------- /Chapter12/OPENROWSET and External Tables Scripts.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter12/OPENROWSET and External Tables Scripts.sql -------------------------------------------------------------------------------- /Chapter12/PurchaseOrders.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter12/PurchaseOrders.csv -------------------------------------------------------------------------------- /Chapter12/Suppliers.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter12/Suppliers.csv -------------------------------------------------------------------------------- /Chapter13/Notebooks/My Analytics/AnalyzingCustomers.ipynb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter13/Notebooks/My Analytics/AnalyzingCustomers.ipynb -------------------------------------------------------------------------------- /Chapter13/Notebooks/My Analytics/Notebook-1.ipynb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter13/Notebooks/My Analytics/Notebook-1.ipynb -------------------------------------------------------------------------------- /Chapter13/Notebooks/My Analytics/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter13/Notebooks/My Analytics/README.md -------------------------------------------------------------------------------- /Chapter13/Notebooks/My Analytics/_config.yml: -------------------------------------------------------------------------------- 1 | title: My Analytics 2 | -------------------------------------------------------------------------------- /Chapter13/Notebooks/My Analytics/_toc.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/Chapter13/Notebooks/My Analytics/_toc.yml -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/LICENSE -------------------------------------------------------------------------------- /OldChapter10/OldChapter10 - Understanding Query Hints.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/OldChapter10/OldChapter10 - Understanding Query Hints.sql -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/SQL-Query-Design-Best-Practices/HEAD/README.md --------------------------------------------------------------------------------