Skip to content

Commit

Permalink
Merge pull request #3736 from szarnyasg/iss3698
Browse files Browse the repository at this point in the history
Iss3698
  • Loading branch information
szarnyasg committed Sep 27, 2024
2 parents af8f15d + 9c87dcb commit 9089259
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions docs/sql/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ FROM weather;
The output should be:

| city | temp_lo | temp_hi | prcp | date |
|---------------|---------|---------|------|------------|
|---------------|--------:|--------:|-----:|------------|
| San Francisco | 46 | 50 | 0.25 | 1994-11-27 |
| San Francisco | 43 | 57 | 0.0 | 1994-11-29 |
| Hayward | 37 | 54 | NULL | 1994-11-29 |
Expand All @@ -137,7 +137,7 @@ FROM weather;
This should give:

| city | temp_avg | date |
|---------------|----------|------------|
|---------------|---------:|------------|
| San Francisco | 48.0 | 1994-11-27 |
| San Francisco | 50.0 | 1994-11-29 |
| Hayward | 45.5 | 1994-11-29 |
Expand All @@ -156,7 +156,7 @@ WHERE city = 'San Francisco'
Result:

| city | temp_lo | temp_hi | prcp | date |
|---------------|---------|---------|------|------------|
|---------------|--------:|--------:|-----:|------------|
| San Francisco | 46 | 50 | 0.25 | 1994-11-27 |

You can request that the results of a query be returned in sorted order:
Expand All @@ -168,10 +168,10 @@ ORDER BY city;
```

| city | temp_lo | temp_hi | prcp | date |
|---------------|---------|---------|------|------------|
|---------------|--------:|--------:|-----:|------------|
| Hayward | 37 | 54 | NULL | 1994-11-29 |
| San Francisco | 46 | 50 | 0.25 | 1994-11-27 |
| San Francisco | 43 | 57 | 0.0 | 1994-11-29 |
| San Francisco | 46 | 50 | 0.25 | 1994-11-27 |

In this example, the sort order isn't fully specified, and so you might get the San Francisco rows in either order. But you'd always get the results shown above if you do:

Expand Down Expand Up @@ -214,7 +214,7 @@ WHERE city = name;
```

| city | temp_lo | temp_hi | prcp | date | name | lat | lon |
|---------------|---------|---------|------|------------|---------------|----------|--------|
|---------------|--------:|--------:|-----:|------------|---------------|---------:|-------:|
| San Francisco | 46 | 50 | 0.25 | 1994-11-27 | San Francisco | -194.000 | 53.000 |
| San Francisco | 43 | 57 | 0.0 | 1994-11-29 | San Francisco | -194.000 | 53.000 |

Expand All @@ -230,7 +230,7 @@ WHERE city = name;
```

| city | temp_lo | temp_hi | prcp | date | lon | lat |
|---------------|---------|---------|------|------------|--------|----------|
|---------------|--------:|--------:|-----:|------------|-------:|---------:|
| San Francisco | 46 | 50 | 0.25 | 1994-11-27 | 53.000 | -194.000 |
| San Francisco | 43 | 57 | 0.0 | 1994-11-29 | 53.000 | -194.000 |

Expand Down Expand Up @@ -264,7 +264,7 @@ LEFT OUTER JOIN cities ON weather.city = cities.name;
```

| city | temp_lo | temp_hi | prcp | date | name | lat | lon |
|---------------|---------|---------|------|------------|---------------|----------|--------|
|---------------|--------:|--------:|-----:|------------|---------------|---------:|-------:|
| San Francisco | 46 | 50 | 0.25 | 1994-11-27 | San Francisco | -194.000 | 53.000 |
| San Francisco | 43 | 57 | 0.0 | 1994-11-29 | San Francisco | -194.000 | 53.000 |
| Hayward | 37 | 54 | NULL | 1994-11-29 | NULL | NULL | NULL |
Expand All @@ -283,7 +283,7 @@ FROM weather;
```

| max(temp_lo) |
|--------------|
|-------------:|
| 46 |

If we wanted to know what city (or cities) that reading occurred in, we might try:
Expand Down Expand Up @@ -331,7 +331,7 @@ HAVING max(temp_lo) < 40;
```

| city | max(temp_lo) |
|---------|--------------|
|---------|-------------:|
| Hayward | 37 |

which gives us the same results for only the cities that have all `temp_lo` values below 40. Finally, if we only care about cities whose names begin with `S`, we can use the `LIKE` operator:
Expand Down Expand Up @@ -368,10 +368,10 @@ FROM weather;
```

| city | temp_lo | temp_hi | prcp | date |
|---------------|---------|---------|------|------------|
|---------------|--------:|--------:|-----:|------------|
| San Francisco | 46 | 50 | 0.25 | 1994-11-27 |
| San Francisco | 43 | 57 | 0.0 | 1994-11-29 |
| Hayward | 37 | 54 | NULL | 1994-11-29 |
| San Francisco | 41 | 55 | 0.0 | 1994-11-29 |
| Hayward | 35 | 52 | NULL | 1994-11-29 |

## Deletions

Expand All @@ -390,9 +390,9 @@ FROM weather;
```

| city | temp_lo | temp_hi | prcp | date |
|---------------|---------|---------|------|------------|
|---------------|--------:|--------:|-----:|------------|
| San Francisco | 46 | 50 | 0.25 | 1994-11-27 |
| San Francisco | 43 | 57 | 0.0 | 1994-11-29 |
| San Francisco | 41 | 55 | 0.0 | 1994-11-29 |

One should be cautious when issuing statements of the following form:

Expand Down

0 comments on commit 9089259

Please sign in to comment.