|
28 | 28 |
|
29 | 29 | ```
|
30 | 30 |
|
31 |
| -### Get annual, average and max spending from customers in all cities |
| 31 | +### Get annual, average, and max spending from customers in all cities |
32 | 32 |
|
33 | 33 | ```SQL
|
34 | 34 | SELECT
|
@@ -58,11 +58,11 @@ GROUP BY city;
|
58 | 58 |
|
59 | 59 | ### Get authors’ bios with books that have an average 5-star rating
|
60 | 60 |
|
61 |
| -We o through 4 stages: |
62 |
| -- group all the reviews for every book, calculating the average rating. |
63 |
| -- filter out all average ratings other than 5. |
64 |
| -- now we have reviews with 5 stars, but we also want the author bio, so we join with author to get the bio. |
65 |
| -- we add a new field called `bio` with just the author's bio. |
| 61 | +We go through four stages: |
| 62 | +- Group all the reviews for every book, calculating the average rating. |
| 63 | +- Filter out all average ratings other than 5. |
| 64 | +- Now we have reviews with 5 stars, but we also want the author bio, so we join with author to get the bio. |
| 65 | +- We add a new field called `bio` with just the author's bio. |
66 | 66 |
|
67 | 67 | ```js
|
68 | 68 | db.reviews.aggregate([
|
@@ -91,7 +91,7 @@ db.reviews.aggregate([
|
91 | 91 | ```
|
92 | 92 |
|
93 | 93 |
|
94 |
| -### Get annual, average and max spending from customers in all cities |
| 94 | +### Get annual, average, and max spending from customers in all cities |
95 | 95 |
|
96 | 96 | Here we pass three stages: one to return one document per element in the `address` array, and then we filter out to get only the documents that have a `home` address location. Finally, we do the grouping. As we'll see, this can be split and tested separately and resembles our code.
|
97 | 97 |
|
|
0 commit comments