From e449424bf97a4006f4be34310b947ea205d02d50 Mon Sep 17 00:00:00 2001 From: singlarohit Date: Sun, 4 Dec 2022 09:58:13 -0500 Subject: [PATCH] Changes agreed by James Foster from Data Carpentry regarding #347 --- episodes/01-sql-basic-queries.md | 2 +- episodes/02-sql-aggregation.md | 4 ++-- episodes/03-sql-joins.md | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/episodes/01-sql-basic-queries.md b/episodes/01-sql-basic-queries.md index cbb9107a..05fd7c83 100644 --- a/episodes/01-sql-basic-queries.md +++ b/episodes/01-sql-basic-queries.md @@ -42,7 +42,7 @@ right after SELECT: ### Limiting results -Sometimes you don't want to see all the results, you just want to get a sense of what's being returned. In that case, you can use the `LIMIT` clause. In particular, you would want to do this if you were working with large databases. +Sometimes you don't want to see all the results, you just want to get a sense of what's being returned. In that case, you can use a `LIMIT` clause. In particular, you would want to do this if you were working with large databases. SELECT * FROM surveys diff --git a/episodes/02-sql-aggregation.md b/episodes/02-sql-aggregation.md index cd79a560..d98aeec2 100644 --- a/episodes/02-sql-aggregation.md +++ b/episodes/02-sql-aggregation.md @@ -241,10 +241,10 @@ we might get tripped up: FROM summer_2000 WHERE species_id = 'PE'; -Here the `COUNT` clause includes all five records (even those with NULL +Here the `COUNT` function includes all five records (even those with NULL values), but the `SUM` only includes the three records with data in the `weight` field, giving us an incorrect average. However, -our strategy *will* work if we modify the `COUNT` clause slightly: +our strategy *will* work if we modify the `COUNT` function slightly: SELECT SUM(weight), COUNT(weight), SUM(weight)/COUNT(weight) FROM summer_2000 diff --git a/episodes/03-sql-joins.md b/episodes/03-sql-joins.md index d0286042..13b1a426 100644 --- a/episodes/03-sql-joins.md +++ b/episodes/03-sql-joins.md @@ -9,7 +9,7 @@ objectives: - "Apply functions to manipulate individual values." - "Employ aliases to assign new names to tables and columns in a query." keypoints: -- "Use the `JOIN` clause to combine data from two tables---the `ON` or `USING` keywords specify which columns link the tables." +- "Use a `JOIN` clause to combine data from two tables---the `ON` or `USING` keywords specify which columns link the tables." - "Regular `JOIN` returns only matching rows. Other join clauses provide different behavior, e.g., `LEFT JOIN` retains all rows of the table on the left side of the clause." - "`COALESCE` allows you to specify a value to use in place of `NULL`, which can help in joins" - "`NULLIF` can be used to replace certain values with `NULL` in results" @@ -18,7 +18,7 @@ keypoints: ## Joins -To combine data from two tables we use the SQL `JOIN` clause, which comes after +To combine data from two tables we use an SQL `JOIN` clause, which comes after the `FROM` clause. @@ -26,10 +26,10 @@ Database tables are used to organize and group data by common characteristics or Often, we need to combine elements from separate tables into a single tables or queries for analysis and visualization. A JOIN is a means for combining columns from multiple tables by using values common to each. -The JOIN clause combined with ON is used to combine fields from separate tables. +The JOIN keyword combined with ON is used to combine fields from separate tables. -The `JOIN` clause on its own will result in a cross product, where each row in +A `JOIN` clause on its own will result in a cross product, where each row in the first table is paired with each row in the second table. Usually this is not what is desired when combining two tables with data that is related in some way. @@ -46,8 +46,8 @@ species id. the `table.colname` format to tell the manager what column in which table we are referring to. -The output of the `JOIN` clause will have columns from the first table plus the -columns from the second table. For the above clause, the output will be a table +The output from using the `JOIN` clause will have columns from the first table plus the +columns from the second table. For the above statement, the output will be a table that has the following column names: | record_id | month | day | year | plot_id | species_id | sex | hindfoot_length | weight | species_id | genus | species | taxa | @@ -136,11 +136,11 @@ survey data. This is because, by default, SQL only returns records where the joining value is present in the joined columns of both tables (i.e. it takes the _intersection_ of the two join columns). This joining behaviour is known as an `INNER JOIN`. -In fact the `JOIN` clause is simply shorthand for `INNER JOIN` and the two +In fact the `JOIN` keyword is simply shorthand for `INNER JOIN` and the two terms can be used interchangably as they will produce the same result. We can also tell the computer that we wish to keep all the records in the first -table by using the clause `LEFT OUTER JOIN`, or `LEFT JOIN` for short. +table by using a `LEFT OUTER JOIN` clause, or `LEFT JOIN` for short. > ## Challenge: >