|
480 | 480 | "\n", |
481 | 481 | "First, I used the `LIMIT` keyword with a value of `10`.\n", |
482 | 482 | "Compustat is a huge dataset, and retrieving everything would be a big download.\n", |
483 | | - "While we are experimenting or iterating on a query, using `LIMIT` asks the server to provide only a number of results up to the parameter to limit.\n", |
| 483 | + "When we are experimenting or iterating on a query, using `LIMIT` asks the server to provide only a number of results up to the parameter to limit.\n", |
484 | 484 | "This is a strong norm when using this kind of data, as it dramatically reduces the load on the server.\n", |
485 | 485 | "`LIMIT` becomes more important as we ask the server to do transformation work for us, which increases the computational demand.\n", |
486 | 486 | "\n", |
|
894 | 894 | "First, we asked for the `cusip` column to be called `cusip9` in our results using `AS`.\n", |
895 | 895 | "Second, we used a function to transform the `cusip` column (using the `SUBSTRING()` function) to give us only eight characters and to name it `cusip8`.\n", |
896 | 896 | "This is a simple example of having the server do prep work for us.\n", |
897 | | - "Finally, we added a second condition to `WHERE`, a year restriction." |
| 897 | + "Finally, we added a second condition to `WHERE`: a year restriction." |
898 | 898 | ] |
899 | 899 | }, |
900 | 900 | { |
|
903 | 903 | "source": [ |
904 | 904 | "# Aggregation\n", |
905 | 905 | "\n", |
906 | | - "Sometimes, the data in a table is more granular than the data that we want out.\n", |
| 906 | + "Sometimes, the data in a table is more granular than the data that we returned to us.\n", |
907 | 907 | "So, we can ask the server to aggregate it for us, returning an aggregated dataset.\n", |
908 | 908 | "\n", |
909 | 909 | "There are a few important things to know:\n", |
910 | 910 | "\n", |
911 | 911 | "1. We use `GROUP BY` to tell the DBMS how to group rows before aggregating.\n", |
912 | 912 | "2. Every column must either be in the `GROUP BY` or have an aggregation function applied. A notable example here is that we ask for the `MAX` of the company name. If the name changes in the rows of the search, the DBMS would need to know how to choose. However, this is enforced as a general rule, not only when there is an actual conflict to resolve.\n", |
913 | | - "3. Order of the statements matter. For example, `WHERE` needs to be after `FROM` and before `GROUP BY`. I've done them here, so it will work, but this is a topic better explored in a book on the topic." |
| 913 | + "3. Order of the statements matter. For example, `WHERE` needs to be after `FROM` and before `GROUP BY`. I've done them here, so it will work, but this is a topic better explored in an introductory book on SQL." |
914 | 914 | ] |
915 | 915 | }, |
916 | 916 | { |
|
0 commit comments