Skip to content

Commit

Permalink
Merge pull request #347 from singlarohit/singla
Browse files Browse the repository at this point in the history
Replacing "command" with more appropriate terms.
  • Loading branch information
jd-foster authored Dec 4, 2022
2 parents f437994 + e449424 commit b6c074e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion episodes/01-sql-basic-queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` command. 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
Expand Down
4 changes: 2 additions & 2 deletions episodes/02-sql-aggregation.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ we might get tripped up:
FROM summer_2000
WHERE species_id = 'PE';
Here the `COUNT` command 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` command slightly:
our strategy *will* work if we modify the `COUNT` function slightly:
SELECT SUM(weight), COUNT(weight), SUM(weight)/COUNT(weight)
FROM summer_2000
Expand Down
20 changes: 10 additions & 10 deletions episodes/03-sql-joins.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ objectives:
- "Apply functions to manipulate individual values."
- "Employ aliases to assign new names to tables and columns in a query."
keypoints:
- "Use the `JOIN` command 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 commands provide different behavior, e.g., `LEFT JOIN` retains all rows of the table on the left side of the command."
- "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"
- "Many other functions like `COALESCE` and `NULLIF` can operate on individual values."
---

## Joins

To combine data from two tables we use the SQL `JOIN` command, which comes after
the `FROM` command.
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 command 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` command 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.

Expand All @@ -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` command will have columns from the first table plus the
columns from the second table. For the above command, 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 |
Expand Down Expand Up @@ -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` command 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 command `LEFT OUTER JOIN`, or `LEFT JOIN` for short.
table by using a `LEFT OUTER JOIN` clause, or `LEFT JOIN` for short.
> ## Challenge:
>
Expand Down

0 comments on commit b6c074e

Please sign in to comment.