Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iss3698 #3736

Merged
merged 2 commits into from
Sep 27, 2024
Merged

Iss3698 #3736

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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