You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tools/sqlcmd/quickstart-sqlcmd-create-container.md
+37-37Lines changed: 37 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,17 +35,17 @@ You can reverse the order to make **sqlcmd** (ODBC) the default again.
35
35
36
36
## What problem will we solve?
37
37
38
-
This quickstart walks through the process of creating a local copy of a database, then querying it to check for data quality issues.
38
+
This quickstart walks through the process of creating a local copy of a database, then querying it to analyze spending by customer.
39
39
40
-
## Create the local copy
40
+
## Create a new container and restore a database
41
41
42
42
Create a new [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] instance in a container using the latest version of [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)]. The command also restores the `WideWorldImporters` database.
43
43
44
-
1.Open a new terminal window and run the following command:
44
+
Open a new terminal window and run the following command:
@@ -57,43 +57,43 @@ In the same terminal window, run the following command:
57
57
sqlcmd open ads
58
58
```
59
59
60
-
1. Now that you have a local copy of your database, you can run a few queries. Here are a few queries you can use to check for data quality issues:
60
+
1. Now that you have a local copy of your database, you can run queries. Here is a query you can use to analyze spending by customer:
61
61
62
62
```sql
63
-
--Look for customers that have ordered but not been billed for anything
64
-
SELECT *
65
-
FROM Sales.Customers c
66
-
INNER JOIN Sales.Orders o
67
-
ON c.CustomerID = o.CustomerID
68
-
LEFT JOIN Sales.Invoices i
69
-
ON c.CustomerID = i.CustomerID
70
-
WHERE i.CustomerID IS NULL;
71
-
72
-
--Look for customers that have not been billed for anything
73
-
SELECT *
74
-
FROM Sales.Customers c
75
-
LEFT JOIN Sales.Invoices i
76
-
ON c.CustomerID = i.CustomerID
77
-
WHERE i.CustomerID IS NULL;
78
-
79
-
--Look for invoices without a customer
80
-
SELECT *
81
-
FROM Sales.Customers c
82
-
RIGHT JOIN Sales.Invoices i
83
-
ON c.CustomerID = i.CustomerID
84
-
WHERE c.CustomerID IS NULL;
85
-
86
-
--Look for orders without a customer
87
-
SELECT *
88
-
FROM Sales.Customers c
89
-
RIGHT JOIN Sales.Orders o
90
-
ON c.CustomerID = o.CustomerID
91
-
WHERE c.CustomerID IS NULL;
63
+
SELECTbg.BuyingGroupName
64
+
,COUNT(DISTINCT i.InvoiceID) AS InvoiceCount
65
+
,COUNT(il.InvoiceLineID) AS InvoiceLineCount
66
+
,SUM(il.LineProfit) AS Profit
67
+
,SUM(il.ExtendedPrice) AS ExtendedPrice
68
+
FROM [Sales].[Invoices] i
69
+
INNER JOIN [Sales].[Customers] c
70
+
ONi.CustomerID=c.CustomerID
71
+
INNER JOINSales.InvoiceLines il
72
+
ONi.InvoiceID=il.InvoiceID
73
+
INNER JOIN [Sales].[BuyingGroups] bg
74
+
ONc.BuyingGroupID=bg.BuyingGroupID
75
+
GROUP BYbg.BuyingGroupName
76
+
UNION
77
+
SELECTc.CustomerName
78
+
,COUNT(DISTINCT i.InvoiceID) AS InvoiceCount
79
+
,COUNT(il.InvoiceLineID) AS InvoiceLineCount
80
+
,SUM(il.LineProfit) AS Profit
81
+
,SUM(il.ExtendedPrice) AS ExtendedPrice
82
+
FROM [Sales].[Invoices] i
83
+
INNER JOIN [Sales].[Customers] c
84
+
ONi.CustomerID=c.CustomerID
85
+
INNER JOINSales.InvoiceLines il
86
+
ONi.InvoiceID=il.InvoiceID
87
+
LEFT JOIN [Sales].[BuyingGroups] bg
88
+
ONc.BuyingGroupID=bg.BuyingGroupID
89
+
WHEREbg.BuyingGroupID IS NULL
90
+
GROUP BYc.CustomerName
91
+
ORDER BY Profit DESC
92
92
```
93
93
94
94
## How did we solve the problem?
95
95
96
-
You were able to quickly create a local copy of a database for development and testing purposes. With a single command, you created a new local instance and restored the most recent backup to it. You then ran another command to connect to it via Azure Data Studio. You then queried the database using [!INCLUDE [name-sos-short](../../includes/name-sos-short.md)] to check for data quality issues.
96
+
You were able to quickly create a local copy of a database for development and testing purposes. With a single command, you created a new local instance and restored the most recent backup to it. You then ran another command to connect to it via Azure Data Studio. You then queried the database using [!INCLUDE [name-sos-short](../../includes/name-sos-short.md)] to analyze spending by customer.
0 commit comments