From bc57470c7113d4af79066d446d036641b592b601 Mon Sep 17 00:00:00 2001 From: Gabor Szarnyas Date: Fri, 27 Sep 2024 10:28:32 +0200 Subject: [PATCH 1/2] SQL introduction: Update table Fixes #3698 --- docs/sql/introduction.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/sql/introduction.md b/docs/sql/introduction.md index ac37cd8012..f001b9fa33 100644 --- a/docs/sql/introduction.md +++ b/docs/sql/introduction.md @@ -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 From 9c87dcb011447ef5e5bfc551912a4c563657cddf Mon Sep 17 00:00:00 2001 From: Gabor Szarnyas Date: Fri, 27 Sep 2024 10:30:33 +0200 Subject: [PATCH 2/2] SQL introduction: Update table formatting --- docs/sql/introduction.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/sql/introduction.md b/docs/sql/introduction.md index f001b9fa33..fdebe4b4dc 100644 --- a/docs/sql/introduction.md +++ b/docs/sql/introduction.md @@ -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 | @@ -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 | @@ -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: @@ -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: @@ -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 | @@ -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 | @@ -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 | @@ -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: @@ -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: @@ -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: