Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit e876d5a

Browse files
authored
Update quickstart to have a more relevant example
1 parent 528929d commit e876d5a

1 file changed

Lines changed: 37 additions & 37 deletions

File tree

docs/tools/sqlcmd/quickstart-sqlcmd-create-container.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ You can reverse the order to make **sqlcmd** (ODBC) the default again.
3535

3636
## What problem will we solve?
3737

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.
3939

40-
## Create the local copy
40+
## Create a new container and restore a database
4141

4242
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.
4343

44-
1. Open a new terminal window and run the following command:
44+
Open a new terminal window and run the following command:
4545

46-
```bash
47-
sqlcmd create mssql --accept-eula --using https://github.com/Microsoft/sql-server-samples/releases/download/wide-world-importers-v1.0/WideWorldImporters-Full.bak
48-
```
46+
```bash
47+
sqlcmd create mssql --accept-eula --using https://github.com/Microsoft/sql-server-samples/releases/download/wide-world-importers-v1.0/WideWorldImporters-Full.bak
48+
```
4949

5050
## Query the database in Azure Data Studio
5151

@@ -57,43 +57,43 @@ In the same terminal window, run the following command:
5757
sqlcmd open ads
5858
```
5959

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:
6161

6262
```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+
SELECT bg.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+
ON i.CustomerID = c.CustomerID
71+
INNER JOIN Sales.InvoiceLines il
72+
ON i.InvoiceID = il.InvoiceID
73+
INNER JOIN [Sales].[BuyingGroups] bg
74+
ON c.BuyingGroupID = bg.BuyingGroupID
75+
GROUP BY bg.BuyingGroupName
76+
UNION
77+
SELECT c.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+
ON i.CustomerID = c.CustomerID
85+
INNER JOIN Sales.InvoiceLines il
86+
ON i.InvoiceID = il.InvoiceID
87+
LEFT JOIN [Sales].[BuyingGroups] bg
88+
ON c.BuyingGroupID = bg.BuyingGroupID
89+
WHERE bg.BuyingGroupID IS NULL
90+
GROUP BY c.CustomerName
91+
ORDER BY Profit DESC
9292
```
9393

9494
## How did we solve the problem?
9595

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.
9797

9898
## Clean up resources
9999

0 commit comments

Comments
 (0)