Skip to content

Commit

Permalink
Changes agreed by James Foster from Data Carpentry regarding #347
Browse files Browse the repository at this point in the history
singlarohit committed Dec 4, 2022
1 parent 6d17113 commit e449424
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion episodes/01-sql-basic-queries.md
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions episodes/02-sql-aggregation.md
Original file line number Diff line number Diff line change
@@ -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
16 changes: 8 additions & 8 deletions episodes/03-sql-joins.md
Original file line number Diff line number Diff line change
@@ -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,18 +18,18 @@ 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.


Database tables are used to organize and group data by common characteristics or principles.
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:
>

0 comments on commit e449424

Please sign in to comment.