Skip to content

Commit 2acfaa0

Browse files
authored
Merge pull request #160 from kaitlinnewson/sql-styles
Codeblock styles and minor typos
2 parents ae076fc + 0bca1a3 commit 2acfaa0

6 files changed

Lines changed: 20 additions & 20 deletions

File tree

episodes/02-selecting-sorting-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ In the first query above, we have capitalized the words `SELECT` and `FROM` beca
4141

4242
Example:
4343

44-
```
44+
```sql
4545
SELECT Title, Authors, ISSNs, Year
4646
FROM Articles;
4747
```

episodes/04-ordering-commenting.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ their effects as we went along. For complex queries, this is a good strategy, t
7272

7373
When the queries become more complex, it can be useful to add comments to express to yourself, or to others, what you are doing with your query. Comments help explain the logic of a section and provide context for anyone reading the query. It's essentially a way of making notes within your SQL. In SQL, comments begin using <code class="language-plaintext highlighter-rouge">\--</code> and end at the end of the line. To mark a whole paragraph as a comment, you can enclose it with the characters /\* and \*/. For example, a commented version of the above query can be written as:
7474

75-
```
75+
```sql
7676
/*In this section, even though JOINS (see link below this code block)
7777
are not introduced until Episode 6, we want to give an example how to
78-
join multiple tables becasue they represent a good example of using
78+
join multiple tables because they represent a good example of using
7979
comments in SQL to explain more complex queries.*/
8080

8181
-- First we mention all the fields we want to display

episodes/06-joins-aliases.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ ON publishers.id = journals.PublisherId;
107107

108108
::::::::::::::::::::::::::::::::::::::: challenge
109109

110-
## Challenge:
110+
## Challenge
111111

112112
Write a query that returns the `Journal_Title`, `Publisher` name, and number of
113113
articles published, ordered by number of articles in descending order.

episodes/08-database-design.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Conceptually, we know that a journal has only one publisher but a publisher can
7676

7777
## More Terminology
7878

79-
The degree of relationship between entities is known as their 'cardinality'. Using the journals-publishers example, the 'publisheres' tble contains a primary key (PK) called 'id'. When the PK is used to create a connection between the original table and a different table, it is called a foreign key (FK) in the other table. To follow the example, we see a field in the 'journal' table called PublisherID that contains the values from the 'id' field in the 'publisher' table, connected the two tables.
79+
The degree of relationship between entities is known as their 'cardinality'. Using the journals-publishers example, the 'publishers' table contains a primary key (PK) called 'id'. When the PK is used to create a connection between the original table and a different table, it is called a foreign key (FK) in the other table. To follow the example, we see a field in the 'journal' table called PublisherID that contains the values from the 'id' field in the 'publisher' table, connecting the two tables.
8080

8181
There are 4 main types of relationships between tables:
8282

episodes/09-create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ stored in any particular order.)
175175

176176
::::::::::::::::::::::::::::::::::::::::::::::::::
177177

178-
Adaped from the Software Carpentry Course "Databases and SQL", Chapter 9. 'Creating and Modifying Data'.
178+
Adapted from the Software Carpentry Course "Databases and SQL", Chapter 9. 'Creating and Modifying Data'.
179179
<https://swcarpentry.github.io/sql-novice-survey/09-create>
180180

181181
:::::::::::::::::::::::::::::::::::::::: keypoints

learners/reference.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,28 @@ title: 'SQL Cheat Sheet'
88

99
### Basic query
1010

11-
```
11+
```sql
1212
SELECT column_names
1313
FROM table_name;
1414
```
1515

1616
- selects only the specified columns from a table.
1717

18-
```
18+
```sql
1919
SELECT *
2020
FROM table_name;
2121
```
2222

2323
- select all of the columns in a table.
2424

25-
```
26-
SELECT DINSTINCT column_name
25+
```sql
26+
SELECT DISTINCT column_name
2727
FROM table_name;
2828
```
2929

3030
- selects only the unique values from a table.
3131

32-
```
32+
```sql
3333
SELECT column_names
3434
FROM table_name
3535
WHERE column_name operator value;
@@ -39,15 +39,15 @@ WHERE column_name operator value;
3939
- you can use operators `=`,`<`,`>`, etc
4040
- you can also combine tests using `AND`, `OR` in the WHERE clause.
4141

42-
```
42+
```sql
4343
SELECT column_names
4444
FROM table_name
4545
WHERE column_name IN (value1, value2, value3);
4646
```
4747

4848
- selects only the data where column\_name equals to `value1`, `value2`, and so on.
4949

50-
```
50+
```sql
5151
SELECT column_names
5252
FROM table_name
5353
ORDER BY column_name ASC;
@@ -59,7 +59,7 @@ ORDER BY column_name ASC;
5959

6060
### Aggregation
6161

62-
```
62+
```sql
6363
SELECT aggregate_function(column_name)
6464
FROM table_name;
6565
```
@@ -68,7 +68,7 @@ FROM table_name;
6868
- E.g. `SELECT COUNT(*) FROM table_name` will display the total number of records.
6969
- You can use aggregate functions `COUNT`, `SUM`, `MAX`, `MIN`, `AVG`.
7070

71-
```
71+
```sql
7272
SELECT column_name, aggregate_function(column_name)
7373
FROM table_name
7474
WHERE column_name operator value
@@ -77,7 +77,7 @@ GROUP BY column_name;
7777

7878
- `GROUP BY` tells SQL what field or fields we want to use to aggregate the data. If we want to group by multiple fields, we give `GROUP BY` a comma separated list.
7979

80-
```
80+
```sql
8181
SELECT column_name, aggregate_function(column_name)
8282
FROM table_name
8383
GROUP BY column_name
@@ -90,7 +90,7 @@ HAVING aggregate_function(column_name) operator value;
9090

9191
### Joins and aliases
9292

93-
```
93+
```sql
9494
SELECT column_names
9595
FROM table_name1
9696
JOIN table_name2
@@ -100,7 +100,7 @@ ON table_name1.column_name = table_name2.column_name;
100100
- Combine data from two tables where the values of column\_name in the two tables are the same.
101101
- Instead of `ON`, you can use the `USING` keyword as a shorthand. E.g. `USING (coolumn_name)`.
102102

103-
```
103+
```sql
104104
SELECT alias1.column_name1, alias1.column_name2, alias2.column_name3
105105
FROM table_name1 AS alias1
106106
JOIN table_name2 AS alias2
@@ -114,7 +114,7 @@ ON alias1.column_name = alias2.column_name;
114114

115115
### Saving queries
116116

117-
```
117+
```sql
118118
CREATE VIEW viewname AS
119119
SELECT column_names
120120
FROM table_name;
@@ -126,7 +126,7 @@ FROM table_name;
126126

127127
### Commenting
128128

129-
```
129+
```sql
130130
-- Select all columns
131131
SELECT *
132132
-- From the table_name

0 commit comments

Comments
 (0)