From 0cb4290b66f4ab252f87d23126719f318d1a2357 Mon Sep 17 00:00:00 2001 From: Todd Schwartz Date: Mon, 15 Dec 2025 18:49:20 -0800 Subject: [PATCH 01/10] Add basic SELECT concept and exercise --- concepts/select/.meta/config.json | 5 + concepts/select/about.md | 142 ++++++++++++++++++ concepts/select/introduction.md | 142 ++++++++++++++++++ concepts/select/links.json | 10 ++ config.json | 18 +++ exercises/concept/intro-select/.docs/hints.md | 0 .../intro-select/.docs/instructions.md | 28 ++++ .../intro-select/.docs/introduction.md | 124 +++++++++++++++ .../concept/intro-select/.meta/config.json | 18 +++ .../concept/intro-select/.meta/design.md | 20 +++ .../concept/intro-select/create_fixture.sql | 10 ++ exercises/concept/intro-select/data.csv | 6 + .../concept/intro-select/intro-select.sql | 19 +++ .../intro-select/intro-select_test.sql | 17 +++ .../concept/intro-select/report-results.sh | 15 ++ exercises/concept/intro-select/test-result.jq | 26 ++++ exercises/concept/intro-select/test_data.json | 43 ++++++ 17 files changed, 643 insertions(+) create mode 100644 concepts/select/.meta/config.json create mode 100644 concepts/select/about.md create mode 100644 concepts/select/introduction.md create mode 100644 concepts/select/links.json create mode 100644 exercises/concept/intro-select/.docs/hints.md create mode 100644 exercises/concept/intro-select/.docs/instructions.md create mode 100644 exercises/concept/intro-select/.docs/introduction.md create mode 100644 exercises/concept/intro-select/.meta/config.json create mode 100644 exercises/concept/intro-select/.meta/design.md create mode 100644 exercises/concept/intro-select/create_fixture.sql create mode 100644 exercises/concept/intro-select/data.csv create mode 100644 exercises/concept/intro-select/intro-select.sql create mode 100644 exercises/concept/intro-select/intro-select_test.sql create mode 100644 exercises/concept/intro-select/report-results.sh create mode 100644 exercises/concept/intro-select/test-result.jq create mode 100644 exercises/concept/intro-select/test_data.json diff --git a/concepts/select/.meta/config.json b/concepts/select/.meta/config.json new file mode 100644 index 00000000..5442fc00 --- /dev/null +++ b/concepts/select/.meta/config.json @@ -0,0 +1,5 @@ +{ + "blurb": "The SQL SELECT statement is the mechanism for querying a database.", + "authors": ["blackk-foxx"], + "contributors": ["blackk-foxx"] +} diff --git a/concepts/select/about.md b/concepts/select/about.md new file mode 100644 index 00000000..acbdc578 --- /dev/null +++ b/concepts/select/about.md @@ -0,0 +1,142 @@ +# The SELECT statement + +In SQL, a `SELECT` statement allows you to retrieve data from a database. +The result of a `SELECT` statement is a result set -- some number of values arranged in rows and columns, where each column is a particular attribute of the data and each row is a set of values for each column. + +Roughly, you can think of the set of columns as a data structure, where each column represents a field of the data structure, and each row represents a concrete instance of the data structure. + +With a `SELECT` statement, you can specify the data you want and optionally transform, filter, and/or modify the shape of the output data. + + +## The basics + +The anatomy of a basic `SELECT` statement is as follows: + +```sql +SELECT +FROM +WHERE ; +``` + +Note that the line breaks are not required; any spacing will suffice to separate the different +clauses (i.e. parts) of the `SELECT` statement. + +Immediately following the `SELECT` keyword is a list of the columns that you want in the result. +The `FROM` clause identifies the source of the data, which is typically a table in the database. +The `WHERE` clause filters the output data by one or more criteria. + + +For example, consider a database with a table named `inventory` containing the following data: + + +| upc | category | supplier | brand | product_name | weight | stock | +|--------------|------------|----------------|-------------|----------------------------------|--------|-------| +| 812345670019 | Cookware | KitchenCo | HearthStone | 10" Non-Stick Skillet | 1.8 | 42 | +| 845678120334 | Utensils | HomePro Supply | PrepMaster | Stainless Steel Ladle | 0.4 | 120 | +| 899001234556 | Appliances | Culinary Depot | QuickBrew | Single-Serve Coffee Maker | 4.2 | 18 | +| 823450987112 | Cookware | KitchenCo | FreshKeep | 12-Piece Glass Container Set | 6 | 33 | +| 867530900221 | Utensils | HomePro Supply | EdgeCraft | 8' Chef's Knife | 0.6 | 27 | +| 880012349876 | Appliances | Culinary Depot | HeatWave | Compact Toaster Oven | 7.5 | 14 | +| 833221109443 | Utensils | HomePro Supply | PureScrub | Heavy-Duty Kitchen Sponge (3-pk) | 0.2 | 200 | +| 899998877665 | Cookware | KitchenCo | IronCraft | Cast-Iron Grill Pan | 5.3 | 21 | +| 844110220987 | Appliances | Culinary Depot | BlendPro | High-Speed Personal Blender | 3.1 | 16 | + +If we want to simply retrieve all of the data from the table, we could run the following query: + +```sql +SELECT * FROM inventory; +``` + +Result: + +``` +upc category supplier brand product_name weight stock +------------ ---------- -------------- ----------- -------------------------------- ------ ----- +812345670019 Cookware KitchenCo HearthStone 10" Non-Stick Skillet 1.8 42 +845678120334 Utensils HomePro Supply PrepMaster Stainless Steel Ladle 0.4 120 +899001234556 Appliances Culinary Depot QuickBrew Single-Serve Coffee Maker 4.2 18 +823450987112 Cookware KitchenCo FreshKeep 12-Piece Glass Container Set 6 33 +867530900221 Utensils HomePro Supply EdgeCraft 8' Chef's Knife 0.6 27 +880012349876 Appliances Culinary Depot HeatWave Compact Toaster Oven 7.5 14 +833221109443 Utensils HomePro Supply PureScrub Heavy-Duty Kitchen Sponge (3-pk) 0.2 200 +899998877665 Cookware KitchenCo IronCraft Cast-Iron Grill Pan 5.3 21 +844110220987 Appliances Culinary Depot BlendPro High-Speed Personal Blender 3.1 16 +``` + +But if we only want the category and product_name values, we could specify those columns: + +```sql +SELECT category, product_name FROM inventory; +``` + +Result: + +``` +category product_name +---------- -------------------------------- +Cookware 10" Non-Stick Skillet +Utensils Stainless Steel Ladle +Appliances Single-Serve Coffee Maker +Cookware 12-Piece Glass Container Set +Utensils 8' Chef's Knife +Appliances Compact Toaster Oven +Utensils Heavy-Duty Kitchen Sponge (3-pk) +Cookware Cast-Iron Grill Pan +Appliances High-Speed Personal Blender +``` + +~~~~exercism/note +The `FROM` clause is optional. +A statement like `SELECT "Hello, world.";` is perfectly valid, and will generate the following result: + +``` +"Hello, world." +--------------- +Hello, world. +``` +~~~~ + +## Filtering data with the WHERE clause + +The `WHERE` clause allows you to filter the data retrieved by a `SELECT` statement. +For example, if we only want Appliances: + +```sql +SELECT * FROM inventory +WHERE category = "Appliances"; +``` + +Result: +``` +upc category supplier brand product_name weight stock +------------ ---------- -------------- --------- --------------------------- ------ ----- +899001234556 Appliances Culinary Depot QuickBrew Single-Serve Coffee Maker 4.2 18 +880012349876 Appliances Culinary Depot HeatWave Compact Toaster Oven 7.5 14 +844110220987 Appliances Culinary Depot BlendPro High-Speed Personal Blender 3.1 16 +``` + + +Or maybe we only want data where the weight is between 2.0 and 6.0: + +```sql +SELECT * FROM inventory +WHERE weight BETWEEN 2.0 AND 6.0; +``` + + +Result: +``` +upc category supplier brand product_name weight stock +------------ ---------- -------------- --------- ---------------------------- ------ ----- +899001234556 Appliances Culinary Depot QuickBrew Single-Serve Coffee Maker 4.2 18 +823450987112 Cookware KitchenCo FreshKeep 12-Piece Glass Container Set 6 33 +899998877665 Cookware KitchenCo IronCraft Cast-Iron Grill Pan 5.3 21 +844110220987 Appliances Culinary Depot BlendPro High-Speed Personal Blender 3.1 16 +``` + + +In addition to `=` and `BETWEEN...AND`, the `WHERE` clause supports a wide range of expressions, including comparison (`<`, `<=`, `>`, `>=`), pattern matching (`LIKE`, `GLOB`, `REGEXP`, `MATCH`), and checking for membership in a list (`IN`, `NOT IN`). +See [SQL Language Expressions](sql-expr) for the complete documentation. + + +[sql-expr]: https://sqlite.org/lang_expr.html diff --git a/concepts/select/introduction.md b/concepts/select/introduction.md new file mode 100644 index 00000000..acbdc578 --- /dev/null +++ b/concepts/select/introduction.md @@ -0,0 +1,142 @@ +# The SELECT statement + +In SQL, a `SELECT` statement allows you to retrieve data from a database. +The result of a `SELECT` statement is a result set -- some number of values arranged in rows and columns, where each column is a particular attribute of the data and each row is a set of values for each column. + +Roughly, you can think of the set of columns as a data structure, where each column represents a field of the data structure, and each row represents a concrete instance of the data structure. + +With a `SELECT` statement, you can specify the data you want and optionally transform, filter, and/or modify the shape of the output data. + + +## The basics + +The anatomy of a basic `SELECT` statement is as follows: + +```sql +SELECT +FROM +WHERE ; +``` + +Note that the line breaks are not required; any spacing will suffice to separate the different +clauses (i.e. parts) of the `SELECT` statement. + +Immediately following the `SELECT` keyword is a list of the columns that you want in the result. +The `FROM` clause identifies the source of the data, which is typically a table in the database. +The `WHERE` clause filters the output data by one or more criteria. + + +For example, consider a database with a table named `inventory` containing the following data: + + +| upc | category | supplier | brand | product_name | weight | stock | +|--------------|------------|----------------|-------------|----------------------------------|--------|-------| +| 812345670019 | Cookware | KitchenCo | HearthStone | 10" Non-Stick Skillet | 1.8 | 42 | +| 845678120334 | Utensils | HomePro Supply | PrepMaster | Stainless Steel Ladle | 0.4 | 120 | +| 899001234556 | Appliances | Culinary Depot | QuickBrew | Single-Serve Coffee Maker | 4.2 | 18 | +| 823450987112 | Cookware | KitchenCo | FreshKeep | 12-Piece Glass Container Set | 6 | 33 | +| 867530900221 | Utensils | HomePro Supply | EdgeCraft | 8' Chef's Knife | 0.6 | 27 | +| 880012349876 | Appliances | Culinary Depot | HeatWave | Compact Toaster Oven | 7.5 | 14 | +| 833221109443 | Utensils | HomePro Supply | PureScrub | Heavy-Duty Kitchen Sponge (3-pk) | 0.2 | 200 | +| 899998877665 | Cookware | KitchenCo | IronCraft | Cast-Iron Grill Pan | 5.3 | 21 | +| 844110220987 | Appliances | Culinary Depot | BlendPro | High-Speed Personal Blender | 3.1 | 16 | + +If we want to simply retrieve all of the data from the table, we could run the following query: + +```sql +SELECT * FROM inventory; +``` + +Result: + +``` +upc category supplier brand product_name weight stock +------------ ---------- -------------- ----------- -------------------------------- ------ ----- +812345670019 Cookware KitchenCo HearthStone 10" Non-Stick Skillet 1.8 42 +845678120334 Utensils HomePro Supply PrepMaster Stainless Steel Ladle 0.4 120 +899001234556 Appliances Culinary Depot QuickBrew Single-Serve Coffee Maker 4.2 18 +823450987112 Cookware KitchenCo FreshKeep 12-Piece Glass Container Set 6 33 +867530900221 Utensils HomePro Supply EdgeCraft 8' Chef's Knife 0.6 27 +880012349876 Appliances Culinary Depot HeatWave Compact Toaster Oven 7.5 14 +833221109443 Utensils HomePro Supply PureScrub Heavy-Duty Kitchen Sponge (3-pk) 0.2 200 +899998877665 Cookware KitchenCo IronCraft Cast-Iron Grill Pan 5.3 21 +844110220987 Appliances Culinary Depot BlendPro High-Speed Personal Blender 3.1 16 +``` + +But if we only want the category and product_name values, we could specify those columns: + +```sql +SELECT category, product_name FROM inventory; +``` + +Result: + +``` +category product_name +---------- -------------------------------- +Cookware 10" Non-Stick Skillet +Utensils Stainless Steel Ladle +Appliances Single-Serve Coffee Maker +Cookware 12-Piece Glass Container Set +Utensils 8' Chef's Knife +Appliances Compact Toaster Oven +Utensils Heavy-Duty Kitchen Sponge (3-pk) +Cookware Cast-Iron Grill Pan +Appliances High-Speed Personal Blender +``` + +~~~~exercism/note +The `FROM` clause is optional. +A statement like `SELECT "Hello, world.";` is perfectly valid, and will generate the following result: + +``` +"Hello, world." +--------------- +Hello, world. +``` +~~~~ + +## Filtering data with the WHERE clause + +The `WHERE` clause allows you to filter the data retrieved by a `SELECT` statement. +For example, if we only want Appliances: + +```sql +SELECT * FROM inventory +WHERE category = "Appliances"; +``` + +Result: +``` +upc category supplier brand product_name weight stock +------------ ---------- -------------- --------- --------------------------- ------ ----- +899001234556 Appliances Culinary Depot QuickBrew Single-Serve Coffee Maker 4.2 18 +880012349876 Appliances Culinary Depot HeatWave Compact Toaster Oven 7.5 14 +844110220987 Appliances Culinary Depot BlendPro High-Speed Personal Blender 3.1 16 +``` + + +Or maybe we only want data where the weight is between 2.0 and 6.0: + +```sql +SELECT * FROM inventory +WHERE weight BETWEEN 2.0 AND 6.0; +``` + + +Result: +``` +upc category supplier brand product_name weight stock +------------ ---------- -------------- --------- ---------------------------- ------ ----- +899001234556 Appliances Culinary Depot QuickBrew Single-Serve Coffee Maker 4.2 18 +823450987112 Cookware KitchenCo FreshKeep 12-Piece Glass Container Set 6 33 +899998877665 Cookware KitchenCo IronCraft Cast-Iron Grill Pan 5.3 21 +844110220987 Appliances Culinary Depot BlendPro High-Speed Personal Blender 3.1 16 +``` + + +In addition to `=` and `BETWEEN...AND`, the `WHERE` clause supports a wide range of expressions, including comparison (`<`, `<=`, `>`, `>=`), pattern matching (`LIKE`, `GLOB`, `REGEXP`, `MATCH`), and checking for membership in a list (`IN`, `NOT IN`). +See [SQL Language Expressions](sql-expr) for the complete documentation. + + +[sql-expr]: https://sqlite.org/lang_expr.html diff --git a/concepts/select/links.json b/concepts/select/links.json new file mode 100644 index 00000000..58fcb18f --- /dev/null +++ b/concepts/select/links.json @@ -0,0 +1,10 @@ +[ + { + "url": "https://sqlite.org/lang_select.html#simple_select_processing", + "description": "Simple SELECT processing details" + }, + { + "url": "https://sqlite.org/lang_select.html", + "description": "Complete SELECT documentation for SQLite" + } +] diff --git a/config.json b/config.json index 4ecaaded..60071b73 100644 --- a/config.json +++ b/config.json @@ -33,6 +33,17 @@ ] }, "exercises": { + "concept": [ + { + "slug": "intro-select", + "name": "SELECT Basics", + "uuid": "1762549a-4622-442d-9aff-4c65f72a955c", + "concepts": [ + "select" + ], + "prerequisites": [] + } + ], "practice": [ { "slug": "hello-world", @@ -716,6 +727,13 @@ "icon": "small" } ], + "concepts": [ + { + "uuid": "92187df0-fb68-4b46-af3b-cc17c2ef6fbc", + "slug": "select", + "name": "SELECT" + } + ], "tags": [ "execution_mode/interpreted", "platform/linux", diff --git a/exercises/concept/intro-select/.docs/hints.md b/exercises/concept/intro-select/.docs/hints.md new file mode 100644 index 00000000..e69de29b diff --git a/exercises/concept/intro-select/.docs/instructions.md b/exercises/concept/intro-select/.docs/instructions.md new file mode 100644 index 00000000..7d5d51f4 --- /dev/null +++ b/exercises/concept/intro-select/.docs/instructions.md @@ -0,0 +1,28 @@ +# Instructions + +You are a data analyst at a firm that analyzes weather data in the Pacific Northwest. You will be working with a database containing a `weather_data` table with the following columns: + +* `date`: The date on which the sample was collected. +* `location`: The name of the city in which the sample was collected. +* `temperature`: The temperature, in degrees Fahrenheit. +* `humidity`: The relative humidity, as a percentage value. + +In each of the following tasks, your job is to gather the specified result set, by using a `SELECT` statement. +Note that in each case, the result set will be stored in a new table -- one table for each task -- via a pre-written `CREATE TABLE` statement. +Your job for each task is to add the appropriate `SELECT` statement within the existing `CREATE TABLE` statement. + +## 1. Gather all of the data + +Gather all of the data from the `weather_data` table. + +## 2. Gather only the location and temperature data + +Gather only the location and temperature values from the `weather_data` table. + +## 3. Gather only data for Seattle + +Gather only the data for the Seattle location. + +## 4. Gather only the data with humidity in a specific range + +Gather only the data where the humidity is between 60% and 70%. \ No newline at end of file diff --git a/exercises/concept/intro-select/.docs/introduction.md b/exercises/concept/intro-select/.docs/introduction.md new file mode 100644 index 00000000..e01d3ca3 --- /dev/null +++ b/exercises/concept/intro-select/.docs/introduction.md @@ -0,0 +1,124 @@ +# Introduction + +In SQL, the `SELECT` statement allows you to retrieve data from a database. +The result of a `SELECT` statement is a result set -- some number of values arranged in rows and columns, where each column is a particular attribute of the data and each row is a set of values for each column. + +Roughly, you can think of the set of columns as a data structure, where each column represents a field of the data structure, and each row represents a concrete instance of the data structure. + +With a `SELECT` statement, you can specify the data you want and optionally transform, filter, and/or modify the shape of the output data. + + +## The basics + +The anatomy of a basic `SELECT` statement is as follows: + +```sql +SELECT +FROM +WHERE ; +``` + +Note that the line breaks are not required; any spacing will suffice to separate the different +clauses (i.e. parts) of the `SELECT` statement. + +Immediately following the `SELECT` keyword is a list of the columns that you want in the result. +The `FROM` clause identifies the source of the data, which is typically a table in the database. +The `WHERE` clause filters the output data by one or more criteria. + + +For example, consider a database with a table named `inventory` containing the following data: + + +| upc | category | supplier | brand | product_name | weight | stock | +|--------------|------------|----------------|-------------|----------------------------------|--------|-------| +| 812345670019 | Cookware | KitchenCo | HearthStone | 10" Non-Stick Skillet | 1.8 | 42 | +| 845678120334 | Utensils | HomePro Supply | PrepMaster | Stainless Steel Ladle | 0.4 | 120 | +| 899001234556 | Appliances | Culinary Depot | QuickBrew | Single-Serve Coffee Maker | 4.2 | 18 | +| 823450987112 | Cookware | KitchenCo | FreshKeep | 12-Piece Glass Container Set | 6 | 33 | +| 867530900221 | Utensils | HomePro Supply | EdgeCraft | 8' Chef's Knife | 0.6 | 27 | +| 880012349876 | Appliances | Culinary Depot | HeatWave | Compact Toaster Oven | 7.5 | 14 | +| 833221109443 | Utensils | HomePro Supply | PureScrub | Heavy-Duty Kitchen Sponge (3-pk) | 0.2 | 200 | +| 899998877665 | Cookware | KitchenCo | IronCraft | Cast-Iron Grill Pan | 5.3 | 21 | +| 844110220987 | Appliances | Culinary Depot | BlendPro | High-Speed Personal Blender | 3.1 | 16 | + +If we want to simply retrieve all of the data from the table, we could run the following query: + +```sql +SELECT * FROM inventory; +``` + +Result: + +``` +upc category supplier brand product_name weight stock +------------ ---------- -------------- ----------- -------------------------------- ------ ----- +812345670019 Cookware KitchenCo HearthStone 10" Non-Stick Skillet 1.8 42 +845678120334 Utensils HomePro Supply PrepMaster Stainless Steel Ladle 0.4 120 +899001234556 Appliances Culinary Depot QuickBrew Single-Serve Coffee Maker 4.2 18 +823450987112 Cookware KitchenCo FreshKeep 12-Piece Glass Container Set 6 33 +867530900221 Utensils HomePro Supply EdgeCraft 8' Chef's Knife 0.6 27 +880012349876 Appliances Culinary Depot HeatWave Compact Toaster Oven 7.5 14 +833221109443 Utensils HomePro Supply PureScrub Heavy-Duty Kitchen Sponge (3-pk) 0.2 200 +899998877665 Cookware KitchenCo IronCraft Cast-Iron Grill Pan 5.3 21 +844110220987 Appliances Culinary Depot BlendPro High-Speed Personal Blender 3.1 16 +``` + +But if we only want the category and product_name values, we could specify those columns: + +```sql +SELECT category, product_name FROM inventory; +``` + +Result: + +``` +category product_name +---------- -------------------------------- +Cookware 10" Non-Stick Skillet +Utensils Stainless Steel Ladle +Appliances Single-Serve Coffee Maker +Cookware 12-Piece Glass Container Set +Utensils 8' Chef's Knife +Appliances Compact Toaster Oven +Utensils Heavy-Duty Kitchen Sponge (3-pk) +Cookware Cast-Iron Grill Pan +Appliances High-Speed Personal Blender +``` + +## Filtering data with the WHERE clause + +The `WHERE` clause allows you to filter the data retrieved by a `SELECT` statement. +For example, if we only want Appliances: + +```sql +SELECT * FROM inventory +WHERE category = "Appliances"; +``` + +Result: +``` +upc category supplier brand product_name weight stock +------------ ---------- -------------- --------- --------------------------- ------ ----- +899001234556 Appliances Culinary Depot QuickBrew Single-Serve Coffee Maker 4.2 18 +880012349876 Appliances Culinary Depot HeatWave Compact Toaster Oven 7.5 14 +844110220987 Appliances Culinary Depot BlendPro High-Speed Personal Blender 3.1 16 +``` + + +Or maybe we only want data where the weight is between 2.0 and 6.0: + +```sql +SELECT * FROM inventory +WHERE weight BETWEEN 2.0 AND 6.0; +``` + + +Result: +``` +upc category supplier brand product_name weight stock +------------ ---------- -------------- --------- ---------------------------- ------ ----- +899001234556 Appliances Culinary Depot QuickBrew Single-Serve Coffee Maker 4.2 18 +823450987112 Cookware KitchenCo FreshKeep 12-Piece Glass Container Set 6 33 +899998877665 Cookware KitchenCo IronCraft Cast-Iron Grill Pan 5.3 21 +844110220987 Appliances Culinary Depot BlendPro High-Speed Personal Blender 3.1 16 +``` diff --git a/exercises/concept/intro-select/.meta/config.json b/exercises/concept/intro-select/.meta/config.json new file mode 100644 index 00000000..b824e6c9 --- /dev/null +++ b/exercises/concept/intro-select/.meta/config.json @@ -0,0 +1,18 @@ +{ + "authors": [ + "blackk-foxx" + ], + "contributors": [ + "IsaacG", + "jimmytty" + ], + "files": { + "solution": [ + "intro-select.sql" + ], + "test": [ + "intro-select_test.sql" + ] + }, + "blurb": "Learn SELECT statement basics" +} diff --git a/exercises/concept/intro-select/.meta/design.md b/exercises/concept/intro-select/.meta/design.md new file mode 100644 index 00000000..9c755b9e --- /dev/null +++ b/exercises/concept/intro-select/.meta/design.md @@ -0,0 +1,20 @@ +# Design + +## Goal + +The goal of this exercise is to teach students the basics of the `SELECT` statement. + +## Learning objectives + +- Know the purpose of the `SELECT` statement. +- Be able to select specific columns from a table. +- Be able to do basic filtering using the `WHERE` clause. + +## Out of scope + +- Advanced filtering +` Subqueries + +## Concepts + +- `select` diff --git a/exercises/concept/intro-select/create_fixture.sql b/exercises/concept/intro-select/create_fixture.sql new file mode 100644 index 00000000..c96de796 --- /dev/null +++ b/exercises/concept/intro-select/create_fixture.sql @@ -0,0 +1,10 @@ +DROP TABLE IF EXISTS weather_readings; +CREATE TABLE weather_readings ( + date TEXT NOT NULL, + location TEXT NOT NULL, + temperature INTEGER NOT NULL, + humidity INTEGER NOT NULL +); + +.mode csv +.import ./data.csv weather_readings diff --git a/exercises/concept/intro-select/data.csv b/exercises/concept/intro-select/data.csv new file mode 100644 index 00000000..cbe5e09a --- /dev/null +++ b/exercises/concept/intro-select/data.csv @@ -0,0 +1,6 @@ +"2025-10-22","Portland",53,72 +"2025-10-22","Seattle",56,66 +"2025-10-22","Boise",60,55 +"2025-10-23","Portland",54,70 +"2025-10-23","Seattle",57,68 +"2025-10-23","Boise",62,58 diff --git a/exercises/concept/intro-select/intro-select.sql b/exercises/concept/intro-select/intro-select.sql new file mode 100644 index 00000000..a09ef43e --- /dev/null +++ b/exercises/concept/intro-select/intro-select.sql @@ -0,0 +1,19 @@ +CREATE TABLE all_data AS + -- Task 1. Select all records. + -- TODO: Add the appropriate SELECT statement here +; + +CREATE TABLE location_and_temperature AS + -- Task 2. Select only location and temperature data. + -- TODO: Add the appropriate SELECT statement here +; + +CREATE TABLE seattle AS + -- Task 3. Select all data for Seattle. + -- TODO: Add the appropriate SELECT statement here +; + +CREATE TABLE limited_humidity AS + -- Task 4. Select all data where the humidity is between 60% and 70%. + -- TODO: Add the appropriate SELECT statement here +; diff --git a/exercises/concept/intro-select/intro-select_test.sql b/exercises/concept/intro-select/intro-select_test.sql new file mode 100644 index 00000000..478311cb --- /dev/null +++ b/exercises/concept/intro-select/intro-select_test.sql @@ -0,0 +1,17 @@ +-- Create database: +.read ./create_fixture.sql + +-- ASK: How can we correlate user output with specific tests? One way is to add .output statements +-- in the stub file. But that introduces more noise into the stub file. + +-- Run user solution and store results +.mode markdown +.output user_output.md +.read ./intro-select.sql +.shell rm -f ./results.db +.save ./results.db + +.output + +-- Report results +.shell bash ./report-results.sh results.db diff --git a/exercises/concept/intro-select/report-results.sh b/exercises/concept/intro-select/report-results.sh new file mode 100644 index 00000000..371a5f46 --- /dev/null +++ b/exercises/concept/intro-select/report-results.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +db_file=$1 +mapfile -t slugs < <(jq -r 'keys[]' test_data.json) + +# Generate result for each test +for slug in "${slugs[@]}"; do + actual=$(sqlite3 -json $db_file "SELECT * FROM ${slug};") + if [[ -z "$actual" ]]; then + actual="[]" + fi + jq -n --slurpfile test_data test_data.json --argjson got "${actual}" --arg slug "${slug}" -f test-result.jq +done > results.txt + +# Aggregate results +jq -n --slurpfile results results.txt '$results' > output.json diff --git a/exercises/concept/intro-select/test-result.jq b/exercises/concept/intro-select/test-result.jq new file mode 100644 index 00000000..4dbced99 --- /dev/null +++ b/exercises/concept/intro-select/test-result.jq @@ -0,0 +1,26 @@ +def columns: + if (. | length) == 0 then [] + else .[0] | keys + end; + +def rows: + map(to_entries | map(.value)); + +def failure_message(got; expected): + (got | columns | tostring) as $got_columns + | (expected | columns | tostring) as $expected_columns + | if $got_columns != $expected_columns then + "Expected columns \($expected_columns); but got \($got_columns)" + else + (got | rows | tostring) as $got_rows + | (expected | rows | tostring) as $expected_rows + | "With columns \($got_columns)\nexpected \($expected_rows)\nbut got \($got_rows)" + end; + +$test_data[0][$slug] +| del(.expected) as $entry +| if $got != .expected then + $entry + {"status": "fail", "message": failure_message($got; .expected)} + else + $entry + {"status": "pass"} + end diff --git a/exercises/concept/intro-select/test_data.json b/exercises/concept/intro-select/test_data.json new file mode 100644 index 00000000..9e83ee9d --- /dev/null +++ b/exercises/concept/intro-select/test_data.json @@ -0,0 +1,43 @@ +{ + "all_data": { + "task_id": 1, + "description": "All data", + "expected": [ + {"date": "2025-10-22", "location": "Portland", "temperature": 53, "humidity": 72}, + {"date": "2025-10-22", "location": "Seattle", "temperature": 56, "humidity": 66}, + {"date": "2025-10-22", "location": "Boise", "temperature": 60, "humidity": 55}, + {"date": "2025-10-23", "location": "Portland", "temperature": 54, "humidity": 70}, + {"date": "2025-10-23", "location": "Seattle", "temperature": 57, "humidity": 68}, + {"date": "2025-10-23", "location": "Boise", "temperature": 62, "humidity": 58} + ] + }, + "location_and_temperature": { + "task_id": 2, + "description": "Just location and temperature", + "expected": [ + {"location": "Portland", "temperature": 53}, + {"location": "Seattle", "temperature": 56}, + {"location": "Boise", "temperature": 60}, + {"location": "Portland", "temperature": 54}, + {"location": "Seattle", "temperature": 57}, + {"location": "Boise", "temperature": 62} + ] + }, + "seattle": { + "task_id": 3, + "description": "Seattle only", + "expected": [ + {"date": "2025-10-22", "location": "Seattle", "temperature": 56, "humidity": 66}, + {"date": "2025-10-23", "location": "Seattle", "temperature": 57, "humidity": 68} + ] + }, + "limited_humidity": { + "task_id": 4, + "description": "Humidity within range", + "expected": [ + {"date": "2025-10-22", "location": "Seattle", "temperature": 56, "humidity": 66}, + {"date": "2025-10-23", "location": "Portland", "temperature": 54, "humidity": 70}, + {"date": "2025-10-23", "location": "Seattle", "temperature": 57, "humidity": 68} + ] + } +} From 5dc7c480806307396756fa10e61c87a036c7f24f Mon Sep 17 00:00:00 2001 From: Todd Schwartz Date: Mon, 15 Dec 2025 22:34:33 -0800 Subject: [PATCH 02/10] Correct table name --- exercises/concept/intro-select/.docs/instructions.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/concept/intro-select/.docs/instructions.md b/exercises/concept/intro-select/.docs/instructions.md index 7d5d51f4..c352ab66 100644 --- a/exercises/concept/intro-select/.docs/instructions.md +++ b/exercises/concept/intro-select/.docs/instructions.md @@ -1,6 +1,6 @@ # Instructions -You are a data analyst at a firm that analyzes weather data in the Pacific Northwest. You will be working with a database containing a `weather_data` table with the following columns: +You are a data analyst at a firm that analyzes weather data in the Pacific Northwest. You will be working with a database containing a `weather_readings` table with the following columns: * `date`: The date on which the sample was collected. * `location`: The name of the city in which the sample was collected. @@ -13,11 +13,11 @@ Your job for each task is to add the appropriate `SELECT` statement within the e ## 1. Gather all of the data -Gather all of the data from the `weather_data` table. +Gather all of the data from the `weather_readings` table. ## 2. Gather only the location and temperature data -Gather only the location and temperature values from the `weather_data` table. +Gather only the location and temperature values from the `weather_readings` table. ## 3. Gather only data for Seattle From 3027614de5ce3a5b8f618e0fa0faf4ee40d02809 Mon Sep 17 00:00:00 2001 From: Todd Schwartz Date: Wed, 17 Dec 2025 11:04:08 -0800 Subject: [PATCH 03/10] Apply suggestions from code review Co-authored-by: Isaac Good --- concepts/select/about.md | 22 ++++++++++--------- .../intro-select/.docs/instructions.md | 12 +++++----- .../concept/intro-select/report-results.sh | 2 +- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/concepts/select/about.md b/concepts/select/about.md index acbdc578..eb340bbe 100644 --- a/concepts/select/about.md +++ b/concepts/select/about.md @@ -1,11 +1,15 @@ # The SELECT statement In SQL, a `SELECT` statement allows you to retrieve data from a database. -The result of a `SELECT` statement is a result set -- some number of values arranged in rows and columns, where each column is a particular attribute of the data and each row is a set of values for each column. +The result of a `SELECT` statement is a result set. +A result set contains values arranged in rows and columns. +Each column is a particular attribute of the data. +Each row contains a value for every column. -Roughly, you can think of the set of columns as a data structure, where each column represents a field of the data structure, and each row represents a concrete instance of the data structure. +One way to think about it is that a set of columns represents a data structure, where each column represents a field of the data structure, and each row represents an instance of the data structure. -With a `SELECT` statement, you can specify the data you want and optionally transform, filter, and/or modify the shape of the output data. +With a `SELECT` statement, you can specify the data you want to retrieve. +You can also optionally transform, filter, and/or modify the shape of the output data. ## The basics @@ -18,8 +22,7 @@ FROM WHERE ; ``` -Note that the line breaks are not required; any spacing will suffice to separate the different -clauses (i.e. parts) of the `SELECT` statement. +Note that the line breaks are not required; any spacing will suffice to separate the different clauses (i.e. parts) of the `SELECT` statement. Immediately following the `SELECT` keyword is a list of the columns that you want in the result. The `FROM` clause identifies the source of the data, which is typically a table in the database. @@ -41,7 +44,7 @@ For example, consider a database with a table named `inventory` containing the f | 899998877665 | Cookware | KitchenCo | IronCraft | Cast-Iron Grill Pan | 5.3 | 21 | | 844110220987 | Appliances | Culinary Depot | BlendPro | High-Speed Personal Blender | 3.1 | 16 | -If we want to simply retrieve all of the data from the table, we could run the following query: +If we want to retrieve all of the data from the table, we could run the following query. ```sql SELECT * FROM inventory; @@ -63,7 +66,7 @@ upc category supplier brand product_name 844110220987 Appliances Culinary Depot BlendPro High-Speed Personal Blender 3.1 16 ``` -But if we only want the category and product_name values, we could specify those columns: +If we only want the category and product_name values, we could specify those columns. ```sql SELECT category, product_name FROM inventory; @@ -99,7 +102,7 @@ Hello, world. ## Filtering data with the WHERE clause The `WHERE` clause allows you to filter the data retrieved by a `SELECT` statement. -For example, if we only want Appliances: +For example, if we only want Appliances, we can do the following. ```sql SELECT * FROM inventory @@ -116,7 +119,7 @@ upc category supplier brand product_name ``` -Or maybe we only want data where the weight is between 2.0 and 6.0: +Or maybe we only want data where the weight is between 2.0 and 6.0. ```sql SELECT * FROM inventory @@ -138,5 +141,4 @@ upc category supplier brand product_name In addition to `=` and `BETWEEN...AND`, the `WHERE` clause supports a wide range of expressions, including comparison (`<`, `<=`, `>`, `>=`), pattern matching (`LIKE`, `GLOB`, `REGEXP`, `MATCH`), and checking for membership in a list (`IN`, `NOT IN`). See [SQL Language Expressions](sql-expr) for the complete documentation. - [sql-expr]: https://sqlite.org/lang_expr.html diff --git a/exercises/concept/intro-select/.docs/instructions.md b/exercises/concept/intro-select/.docs/instructions.md index c352ab66..91f27b64 100644 --- a/exercises/concept/intro-select/.docs/instructions.md +++ b/exercises/concept/intro-select/.docs/instructions.md @@ -1,14 +1,16 @@ # Instructions -You are a data analyst at a firm that analyzes weather data in the Pacific Northwest. You will be working with a database containing a `weather_readings` table with the following columns: +You are a data analyst at a firm that analyzes weather data in the Pacific Northwest. +You will be working with a database containing a `weather_readings` table with the following columns. -* `date`: The date on which the sample was collected. -* `location`: The name of the city in which the sample was collected. -* `temperature`: The temperature, in degrees Fahrenheit. -* `humidity`: The relative humidity, as a percentage value. +* `date`: The date on which the sample was collected. +* `location`: The name of the city in which the sample was collected. +* `temperature`: The temperature, in degrees Fahrenheit. +* `humidity`: The relative humidity, as a percentage value. In each of the following tasks, your job is to gather the specified result set, by using a `SELECT` statement. Note that in each case, the result set will be stored in a new table -- one table for each task -- via a pre-written `CREATE TABLE` statement. +For now, don't worry about the `CREATE TABLE`; that will be covered in another lesson. Your job for each task is to add the appropriate `SELECT` statement within the existing `CREATE TABLE` statement. ## 1. Gather all of the data diff --git a/exercises/concept/intro-select/report-results.sh b/exercises/concept/intro-select/report-results.sh index 371a5f46..70e2be0c 100644 --- a/exercises/concept/intro-select/report-results.sh +++ b/exercises/concept/intro-select/report-results.sh @@ -4,7 +4,7 @@ mapfile -t slugs < <(jq -r 'keys[]' test_data.json) # Generate result for each test for slug in "${slugs[@]}"; do - actual=$(sqlite3 -json $db_file "SELECT * FROM ${slug};") + actual=$(sqlite3 -json "$db_file" "SELECT * FROM ${slug};") if [[ -z "$actual" ]]; then actual="[]" fi From 14dc57c8f038709c2bd651dafc655790d183089c Mon Sep 17 00:00:00 2001 From: Todd Schwartz Date: Wed, 17 Dec 2025 11:41:29 -0800 Subject: [PATCH 04/10] Apply review feedback --- concepts/select/about.md | 30 ++++++------- concepts/select/introduction.md | 44 ++++++++++--------- .../intro-select/.docs/introduction.md | 32 ++++++++++---- 3 files changed, 61 insertions(+), 45 deletions(-) diff --git a/concepts/select/about.md b/concepts/select/about.md index eb340bbe..19747638 100644 --- a/concepts/select/about.md +++ b/concepts/select/about.md @@ -24,6 +24,17 @@ WHERE ; Note that the line breaks are not required; any spacing will suffice to separate the different clauses (i.e. parts) of the `SELECT` statement. +~~~~exercism/note +The `FROM` and `WHERE` clauses are optional. +A statement like `SELECT "Hello, world.";` is perfectly valid, and will generate the following result: + +``` +"Hello, world." +--------------- +Hello, world. +``` +~~~~ + Immediately following the `SELECT` keyword is a list of the columns that you want in the result. The `FROM` clause identifies the source of the data, which is typically a table in the database. The `WHERE` clause filters the output data by one or more criteria. @@ -44,7 +55,7 @@ For example, consider a database with a table named `inventory` containing the f | 899998877665 | Cookware | KitchenCo | IronCraft | Cast-Iron Grill Pan | 5.3 | 21 | | 844110220987 | Appliances | Culinary Depot | BlendPro | High-Speed Personal Blender | 3.1 | 16 | -If we want to retrieve all of the data from the table, we could run the following query. +If we want to retrieve all of the data from the table, we could run the following query: ```sql SELECT * FROM inventory; @@ -66,7 +77,7 @@ upc category supplier brand product_name 844110220987 Appliances Culinary Depot BlendPro High-Speed Personal Blender 3.1 16 ``` -If we only want the category and product_name values, we could specify those columns. +If we only want the category and product_name values, we could specify those columns: ```sql SELECT category, product_name FROM inventory; @@ -88,21 +99,10 @@ Cookware Cast-Iron Grill Pan Appliances High-Speed Personal Blender ``` -~~~~exercism/note -The `FROM` clause is optional. -A statement like `SELECT "Hello, world.";` is perfectly valid, and will generate the following result: - -``` -"Hello, world." ---------------- -Hello, world. -``` -~~~~ - ## Filtering data with the WHERE clause The `WHERE` clause allows you to filter the data retrieved by a `SELECT` statement. -For example, if we only want Appliances, we can do the following. +For example, if we only want Appliances, we can do the following: ```sql SELECT * FROM inventory @@ -119,7 +119,7 @@ upc category supplier brand product_name ``` -Or maybe we only want data where the weight is between 2.0 and 6.0. +Or maybe we only want data where the weight is between 2.0 and 6.0: ```sql SELECT * FROM inventory diff --git a/concepts/select/introduction.md b/concepts/select/introduction.md index acbdc578..2fff091c 100644 --- a/concepts/select/introduction.md +++ b/concepts/select/introduction.md @@ -1,11 +1,15 @@ -# The SELECT statement +# Introduction In SQL, a `SELECT` statement allows you to retrieve data from a database. -The result of a `SELECT` statement is a result set -- some number of values arranged in rows and columns, where each column is a particular attribute of the data and each row is a set of values for each column. +The result of a `SELECT` statement is a result set. +A result set contains values arranged in rows and columns. +Each column is a particular attribute of the data. +Each row contains a value for every column. -Roughly, you can think of the set of columns as a data structure, where each column represents a field of the data structure, and each row represents a concrete instance of the data structure. +One way to think about it is that a set of columns represents a data structure, where each column represents a field of the data structure, and each row represents an instance of the data structure. -With a `SELECT` statement, you can specify the data you want and optionally transform, filter, and/or modify the shape of the output data. +With a `SELECT` statement, you can specify the data you want to retrieve. +You can also optionally transform, filter, and/or modify the shape of the output data. ## The basics @@ -18,8 +22,18 @@ FROM WHERE ; ``` -Note that the line breaks are not required; any spacing will suffice to separate the different -clauses (i.e. parts) of the `SELECT` statement. +Note that the line breaks are not required; any spacing will suffice to separate the different clauses (i.e. parts) of the `SELECT` statement. + +~~~~exercism/note +The `FROM` and `WHERE` clauses are optional. +A statement like `SELECT "Hello, world.";` is perfectly valid, and will generate the following result: + +``` +"Hello, world." +--------------- +Hello, world. +``` +~~~~ Immediately following the `SELECT` keyword is a list of the columns that you want in the result. The `FROM` clause identifies the source of the data, which is typically a table in the database. @@ -41,7 +55,7 @@ For example, consider a database with a table named `inventory` containing the f | 899998877665 | Cookware | KitchenCo | IronCraft | Cast-Iron Grill Pan | 5.3 | 21 | | 844110220987 | Appliances | Culinary Depot | BlendPro | High-Speed Personal Blender | 3.1 | 16 | -If we want to simply retrieve all of the data from the table, we could run the following query: +If we want to retrieve all of the data from the table, we could run the following query: ```sql SELECT * FROM inventory; @@ -63,7 +77,7 @@ upc category supplier brand product_name 844110220987 Appliances Culinary Depot BlendPro High-Speed Personal Blender 3.1 16 ``` -But if we only want the category and product_name values, we could specify those columns: +If we only want the category and product_name values, we could specify those columns: ```sql SELECT category, product_name FROM inventory; @@ -85,21 +99,10 @@ Cookware Cast-Iron Grill Pan Appliances High-Speed Personal Blender ``` -~~~~exercism/note -The `FROM` clause is optional. -A statement like `SELECT "Hello, world.";` is perfectly valid, and will generate the following result: - -``` -"Hello, world." ---------------- -Hello, world. -``` -~~~~ - ## Filtering data with the WHERE clause The `WHERE` clause allows you to filter the data retrieved by a `SELECT` statement. -For example, if we only want Appliances: +For example, if we only want Appliances, we can do the following: ```sql SELECT * FROM inventory @@ -138,5 +141,4 @@ upc category supplier brand product_name In addition to `=` and `BETWEEN...AND`, the `WHERE` clause supports a wide range of expressions, including comparison (`<`, `<=`, `>`, `>=`), pattern matching (`LIKE`, `GLOB`, `REGEXP`, `MATCH`), and checking for membership in a list (`IN`, `NOT IN`). See [SQL Language Expressions](sql-expr) for the complete documentation. - [sql-expr]: https://sqlite.org/lang_expr.html diff --git a/exercises/concept/intro-select/.docs/introduction.md b/exercises/concept/intro-select/.docs/introduction.md index e01d3ca3..306928eb 100644 --- a/exercises/concept/intro-select/.docs/introduction.md +++ b/exercises/concept/intro-select/.docs/introduction.md @@ -1,11 +1,15 @@ # Introduction -In SQL, the `SELECT` statement allows you to retrieve data from a database. -The result of a `SELECT` statement is a result set -- some number of values arranged in rows and columns, where each column is a particular attribute of the data and each row is a set of values for each column. +In SQL, a `SELECT` statement allows you to retrieve data from a database. +The result of a `SELECT` statement is a result set. +A result set contains values arranged in rows and columns. +Each column is a particular attribute of the data. +Each row contains a value for every column. -Roughly, you can think of the set of columns as a data structure, where each column represents a field of the data structure, and each row represents a concrete instance of the data structure. +One way to think about it is that a set of columns represents a data structure, where each column represents a field of the data structure, and each row represents an instance of the data structure. -With a `SELECT` statement, you can specify the data you want and optionally transform, filter, and/or modify the shape of the output data. +With a `SELECT` statement, you can specify the data you want to retrieve. +You can also optionally transform, filter, and/or modify the shape of the output data. ## The basics @@ -18,8 +22,18 @@ FROM WHERE ; ``` -Note that the line breaks are not required; any spacing will suffice to separate the different -clauses (i.e. parts) of the `SELECT` statement. +Note that the line breaks are not required; any spacing will suffice to separate the different clauses (i.e. parts) of the `SELECT` statement. + +~~~~exercism/note +The `FROM` and `WHERE` clauses are optional. +A statement like `SELECT "Hello, world.";` is perfectly valid, and will generate the following result: + +``` +"Hello, world." +--------------- +Hello, world. +``` +~~~~ Immediately following the `SELECT` keyword is a list of the columns that you want in the result. The `FROM` clause identifies the source of the data, which is typically a table in the database. @@ -41,7 +55,7 @@ For example, consider a database with a table named `inventory` containing the f | 899998877665 | Cookware | KitchenCo | IronCraft | Cast-Iron Grill Pan | 5.3 | 21 | | 844110220987 | Appliances | Culinary Depot | BlendPro | High-Speed Personal Blender | 3.1 | 16 | -If we want to simply retrieve all of the data from the table, we could run the following query: +If we want to retrieve all of the data from the table, we could run the following query: ```sql SELECT * FROM inventory; @@ -63,7 +77,7 @@ upc category supplier brand product_name 844110220987 Appliances Culinary Depot BlendPro High-Speed Personal Blender 3.1 16 ``` -But if we only want the category and product_name values, we could specify those columns: +If we only want the category and product_name values, we could specify those columns: ```sql SELECT category, product_name FROM inventory; @@ -88,7 +102,7 @@ Appliances High-Speed Personal Blender ## Filtering data with the WHERE clause The `WHERE` clause allows you to filter the data retrieved by a `SELECT` statement. -For example, if we only want Appliances: +For example, if we only want Appliances, we can do the following: ```sql SELECT * FROM inventory From 1e2f7ee1d329c678381ad6fb28eb2b2302bfa895 Mon Sep 17 00:00:00 2001 From: Todd Schwartz Date: Wed, 17 Dec 2025 11:50:19 -0800 Subject: [PATCH 05/10] Remove redundant blank lines --- concepts/select/about.md | 6 ------ concepts/select/introduction.md | 6 ------ exercises/concept/intro-select/.docs/introduction.md | 5 ----- 3 files changed, 17 deletions(-) diff --git a/concepts/select/about.md b/concepts/select/about.md index 19747638..8a53a033 100644 --- a/concepts/select/about.md +++ b/concepts/select/about.md @@ -11,7 +11,6 @@ One way to think about it is that a set of columns represents a data structure, With a `SELECT` statement, you can specify the data you want to retrieve. You can also optionally transform, filter, and/or modify the shape of the output data. - ## The basics The anatomy of a basic `SELECT` statement is as follows: @@ -39,10 +38,8 @@ Immediately following the `SELECT` keyword is a list of the columns that you wan The `FROM` clause identifies the source of the data, which is typically a table in the database. The `WHERE` clause filters the output data by one or more criteria. - For example, consider a database with a table named `inventory` containing the following data: - | upc | category | supplier | brand | product_name | weight | stock | |--------------|------------|----------------|-------------|----------------------------------|--------|-------| | 812345670019 | Cookware | KitchenCo | HearthStone | 10" Non-Stick Skillet | 1.8 | 42 | @@ -118,7 +115,6 @@ upc category supplier brand product_name 844110220987 Appliances Culinary Depot BlendPro High-Speed Personal Blender 3.1 16 ``` - Or maybe we only want data where the weight is between 2.0 and 6.0: ```sql @@ -126,7 +122,6 @@ SELECT * FROM inventory WHERE weight BETWEEN 2.0 AND 6.0; ``` - Result: ``` upc category supplier brand product_name weight stock @@ -137,7 +132,6 @@ upc category supplier brand product_name 844110220987 Appliances Culinary Depot BlendPro High-Speed Personal Blender 3.1 16 ``` - In addition to `=` and `BETWEEN...AND`, the `WHERE` clause supports a wide range of expressions, including comparison (`<`, `<=`, `>`, `>=`), pattern matching (`LIKE`, `GLOB`, `REGEXP`, `MATCH`), and checking for membership in a list (`IN`, `NOT IN`). See [SQL Language Expressions](sql-expr) for the complete documentation. diff --git a/concepts/select/introduction.md b/concepts/select/introduction.md index 2fff091c..1ec34862 100644 --- a/concepts/select/introduction.md +++ b/concepts/select/introduction.md @@ -11,7 +11,6 @@ One way to think about it is that a set of columns represents a data structure, With a `SELECT` statement, you can specify the data you want to retrieve. You can also optionally transform, filter, and/or modify the shape of the output data. - ## The basics The anatomy of a basic `SELECT` statement is as follows: @@ -39,10 +38,8 @@ Immediately following the `SELECT` keyword is a list of the columns that you wan The `FROM` clause identifies the source of the data, which is typically a table in the database. The `WHERE` clause filters the output data by one or more criteria. - For example, consider a database with a table named `inventory` containing the following data: - | upc | category | supplier | brand | product_name | weight | stock | |--------------|------------|----------------|-------------|----------------------------------|--------|-------| | 812345670019 | Cookware | KitchenCo | HearthStone | 10" Non-Stick Skillet | 1.8 | 42 | @@ -118,7 +115,6 @@ upc category supplier brand product_name 844110220987 Appliances Culinary Depot BlendPro High-Speed Personal Blender 3.1 16 ``` - Or maybe we only want data where the weight is between 2.0 and 6.0: ```sql @@ -126,7 +122,6 @@ SELECT * FROM inventory WHERE weight BETWEEN 2.0 AND 6.0; ``` - Result: ``` upc category supplier brand product_name weight stock @@ -137,7 +132,6 @@ upc category supplier brand product_name 844110220987 Appliances Culinary Depot BlendPro High-Speed Personal Blender 3.1 16 ``` - In addition to `=` and `BETWEEN...AND`, the `WHERE` clause supports a wide range of expressions, including comparison (`<`, `<=`, `>`, `>=`), pattern matching (`LIKE`, `GLOB`, `REGEXP`, `MATCH`), and checking for membership in a list (`IN`, `NOT IN`). See [SQL Language Expressions](sql-expr) for the complete documentation. diff --git a/exercises/concept/intro-select/.docs/introduction.md b/exercises/concept/intro-select/.docs/introduction.md index 306928eb..a7730f08 100644 --- a/exercises/concept/intro-select/.docs/introduction.md +++ b/exercises/concept/intro-select/.docs/introduction.md @@ -11,7 +11,6 @@ One way to think about it is that a set of columns represents a data structure, With a `SELECT` statement, you can specify the data you want to retrieve. You can also optionally transform, filter, and/or modify the shape of the output data. - ## The basics The anatomy of a basic `SELECT` statement is as follows: @@ -39,10 +38,8 @@ Immediately following the `SELECT` keyword is a list of the columns that you wan The `FROM` clause identifies the source of the data, which is typically a table in the database. The `WHERE` clause filters the output data by one or more criteria. - For example, consider a database with a table named `inventory` containing the following data: - | upc | category | supplier | brand | product_name | weight | stock | |--------------|------------|----------------|-------------|----------------------------------|--------|-------| | 812345670019 | Cookware | KitchenCo | HearthStone | 10" Non-Stick Skillet | 1.8 | 42 | @@ -118,7 +115,6 @@ upc category supplier brand product_name 844110220987 Appliances Culinary Depot BlendPro High-Speed Personal Blender 3.1 16 ``` - Or maybe we only want data where the weight is between 2.0 and 6.0: ```sql @@ -126,7 +122,6 @@ SELECT * FROM inventory WHERE weight BETWEEN 2.0 AND 6.0; ``` - Result: ``` upc category supplier brand product_name weight stock From dfa35709566832bde07af59c83f36f9b931b6c65 Mon Sep 17 00:00:00 2001 From: Todd Schwartz Date: Wed, 17 Dec 2025 12:02:42 -0800 Subject: [PATCH 06/10] Address review feedback --- .../intro-select/.docs/instructions.md | 20 +++++++++---------- .../concept/intro-select/intro-select.sql | 8 ++++---- .../intro-select/intro-select_test.sql | 7 ++----- .../{report-results.sh => report-results} | 0 exercises/concept/intro-select/test-result.jq | 2 +- 5 files changed, 17 insertions(+), 20 deletions(-) rename exercises/concept/intro-select/{report-results.sh => report-results} (100%) diff --git a/exercises/concept/intro-select/.docs/instructions.md b/exercises/concept/intro-select/.docs/instructions.md index 91f27b64..481ec555 100644 --- a/exercises/concept/intro-select/.docs/instructions.md +++ b/exercises/concept/intro-select/.docs/instructions.md @@ -8,23 +8,23 @@ You will be working with a database containing a `weather_readings` table with t * `temperature`: The temperature, in degrees Fahrenheit. * `humidity`: The relative humidity, as a percentage value. -In each of the following tasks, your job is to gather the specified result set, by using a `SELECT` statement. +In each of the following tasks, your job is to retrieve the specified result set, by using a `SELECT` statement. Note that in each case, the result set will be stored in a new table -- one table for each task -- via a pre-written `CREATE TABLE` statement. For now, don't worry about the `CREATE TABLE`; that will be covered in another lesson. -Your job for each task is to add the appropriate `SELECT` statement within the existing `CREATE TABLE` statement. +Just focus on adding the appropriate `SELECT` statement to accomplish the given task. -## 1. Gather all of the data +## 1. Retrieve all of the data -Gather all of the data from the `weather_readings` table. +Retrieve all of the data from the `weather_readings` table. -## 2. Gather only the location and temperature data +## 2. Retrieve only the location and temperature data -Gather only the location and temperature values from the `weather_readings` table. +Retrieve only the location and temperature values from the `weather_readings` table. -## 3. Gather only data for Seattle +## 3. Retrieve only data for Seattle -Gather only the data for the Seattle location. +Retrieve only the data for the Seattle location. -## 4. Gather only the data with humidity in a specific range +## 4. Retrieve only the data with humidity in a specific range -Gather only the data where the humidity is between 60% and 70%. \ No newline at end of file +Retrieve only the data where the humidity is between 60% and 70%. \ No newline at end of file diff --git a/exercises/concept/intro-select/intro-select.sql b/exercises/concept/intro-select/intro-select.sql index a09ef43e..b76ba979 100644 --- a/exercises/concept/intro-select/intro-select.sql +++ b/exercises/concept/intro-select/intro-select.sql @@ -1,19 +1,19 @@ CREATE TABLE all_data AS -- Task 1. Select all records. - -- TODO: Add the appropriate SELECT statement here + SELECT "TODO: Replace this SELECT statement as needed to accomplish the task" ; CREATE TABLE location_and_temperature AS -- Task 2. Select only location and temperature data. - -- TODO: Add the appropriate SELECT statement here + SELECT "TODO: Replace this SELECT statement as needed to accomplish the task" ; CREATE TABLE seattle AS -- Task 3. Select all data for Seattle. - -- TODO: Add the appropriate SELECT statement here + SELECT "TODO: Replace this SELECT statement as needed to accomplish the task" ; CREATE TABLE limited_humidity AS -- Task 4. Select all data where the humidity is between 60% and 70%. - -- TODO: Add the appropriate SELECT statement here + SELECT "TODO: Replace this SELECT statement as needed to accomplish the task" ; diff --git a/exercises/concept/intro-select/intro-select_test.sql b/exercises/concept/intro-select/intro-select_test.sql index 478311cb..6609a7cf 100644 --- a/exercises/concept/intro-select/intro-select_test.sql +++ b/exercises/concept/intro-select/intro-select_test.sql @@ -1,17 +1,14 @@ -- Create database: .read ./create_fixture.sql --- ASK: How can we correlate user output with specific tests? One way is to add .output statements --- in the stub file. But that introduces more noise into the stub file. - -- Run user solution and store results .mode markdown .output user_output.md .read ./intro-select.sql -.shell rm -f ./results.db .save ./results.db .output -- Report results -.shell bash ./report-results.sh results.db +.shell bash ./report-results results.db +.shell rm -f ./results.db diff --git a/exercises/concept/intro-select/report-results.sh b/exercises/concept/intro-select/report-results similarity index 100% rename from exercises/concept/intro-select/report-results.sh rename to exercises/concept/intro-select/report-results diff --git a/exercises/concept/intro-select/test-result.jq b/exercises/concept/intro-select/test-result.jq index 4dbced99..4686e6d2 100644 --- a/exercises/concept/intro-select/test-result.jq +++ b/exercises/concept/intro-select/test-result.jq @@ -14,7 +14,7 @@ def failure_message(got; expected): else (got | rows | tostring) as $got_rows | (expected | rows | tostring) as $expected_rows - | "With columns \($got_columns)\nexpected \($expected_rows)\nbut got \($got_rows)" + | "With columns \($got_columns)\nexpected rows \($expected_rows)\nbut got \($got_rows)" end; $test_data[0][$slug] From 1ad14e9ccb322e1952544f07995dc575d290f62a Mon Sep 17 00:00:00 2001 From: Todd Schwartz Date: Thu, 18 Dec 2025 16:07:21 -0800 Subject: [PATCH 07/10] Apply review feedback --- concepts/select/about.md | 10 ++-------- concepts/select/introduction.md | 10 ++-------- config.json | 4 ++-- .../{intro-select => weather-report}/.docs/hints.md | 0 .../.docs/instructions.md | 0 .../.docs/introduction.md | 10 ++-------- .../{intro-select => weather-report}/.meta/config.json | 4 ++-- .../{intro-select => weather-report}/.meta/design.md | 0 .../create_fixture.sql | 0 .../concept/{intro-select => weather-report}/data.csv | 0 .../{intro-select => weather-report}/report-results | 0 .../{intro-select => weather-report}/test-result.jq | 0 .../{intro-select => weather-report}/test_data.json | 0 .../weather-report.sql} | 0 .../weather-report_test.sql} | 2 +- 15 files changed, 11 insertions(+), 29 deletions(-) rename exercises/concept/{intro-select => weather-report}/.docs/hints.md (100%) rename exercises/concept/{intro-select => weather-report}/.docs/instructions.md (100%) rename exercises/concept/{intro-select => weather-report}/.docs/introduction.md (95%) rename exercises/concept/{intro-select => weather-report}/.meta/config.json (77%) rename exercises/concept/{intro-select => weather-report}/.meta/design.md (100%) rename exercises/concept/{intro-select => weather-report}/create_fixture.sql (100%) rename exercises/concept/{intro-select => weather-report}/data.csv (100%) rename exercises/concept/{intro-select => weather-report}/report-results (100%) rename exercises/concept/{intro-select => weather-report}/test-result.jq (100%) rename exercises/concept/{intro-select => weather-report}/test_data.json (100%) rename exercises/concept/{intro-select/intro-select.sql => weather-report/weather-report.sql} (100%) rename exercises/concept/{intro-select/intro-select_test.sql => weather-report/weather-report_test.sql} (89%) diff --git a/concepts/select/about.md b/concepts/select/about.md index 8a53a033..f0d88dbc 100644 --- a/concepts/select/about.md +++ b/concepts/select/about.md @@ -21,17 +21,11 @@ FROM WHERE ; ``` -Note that the line breaks are not required; any spacing will suffice to separate the different clauses (i.e. parts) of the `SELECT` statement. - ~~~~exercism/note The `FROM` and `WHERE` clauses are optional. -A statement like `SELECT "Hello, world.";` is perfectly valid, and will generate the following result: +For example, a statement like `SELECT "Hello, world.";` is perfectly valid. -``` -"Hello, world." ---------------- -Hello, world. -``` +Also note that the line breaks are not required; any spacing will suffice to separate the different clauses (i.e. parts) of the `SELECT` statement. ~~~~ Immediately following the `SELECT` keyword is a list of the columns that you want in the result. diff --git a/concepts/select/introduction.md b/concepts/select/introduction.md index 1ec34862..1f799474 100644 --- a/concepts/select/introduction.md +++ b/concepts/select/introduction.md @@ -21,17 +21,11 @@ FROM WHERE ; ``` -Note that the line breaks are not required; any spacing will suffice to separate the different clauses (i.e. parts) of the `SELECT` statement. - ~~~~exercism/note The `FROM` and `WHERE` clauses are optional. -A statement like `SELECT "Hello, world.";` is perfectly valid, and will generate the following result: +For example, a statement like `SELECT "Hello, world.";` is perfectly valid. -``` -"Hello, world." ---------------- -Hello, world. -``` +Also note that the line breaks are not required; any spacing will suffice to separate the different clauses (i.e. parts) of the `SELECT` statement. ~~~~ Immediately following the `SELECT` keyword is a list of the columns that you want in the result. diff --git a/config.json b/config.json index 60071b73..db8c5767 100644 --- a/config.json +++ b/config.json @@ -35,8 +35,8 @@ "exercises": { "concept": [ { - "slug": "intro-select", - "name": "SELECT Basics", + "slug": "weather-report", + "name": "Weather Report", "uuid": "1762549a-4622-442d-9aff-4c65f72a955c", "concepts": [ "select" diff --git a/exercises/concept/intro-select/.docs/hints.md b/exercises/concept/weather-report/.docs/hints.md similarity index 100% rename from exercises/concept/intro-select/.docs/hints.md rename to exercises/concept/weather-report/.docs/hints.md diff --git a/exercises/concept/intro-select/.docs/instructions.md b/exercises/concept/weather-report/.docs/instructions.md similarity index 100% rename from exercises/concept/intro-select/.docs/instructions.md rename to exercises/concept/weather-report/.docs/instructions.md diff --git a/exercises/concept/intro-select/.docs/introduction.md b/exercises/concept/weather-report/.docs/introduction.md similarity index 95% rename from exercises/concept/intro-select/.docs/introduction.md rename to exercises/concept/weather-report/.docs/introduction.md index a7730f08..5dd323c9 100644 --- a/exercises/concept/intro-select/.docs/introduction.md +++ b/exercises/concept/weather-report/.docs/introduction.md @@ -21,17 +21,11 @@ FROM WHERE ; ``` -Note that the line breaks are not required; any spacing will suffice to separate the different clauses (i.e. parts) of the `SELECT` statement. - ~~~~exercism/note The `FROM` and `WHERE` clauses are optional. -A statement like `SELECT "Hello, world.";` is perfectly valid, and will generate the following result: +For example, a statement like `SELECT "Hello, world.";` is perfectly valid. -``` -"Hello, world." ---------------- -Hello, world. -``` +Also note that the line breaks are not required; any spacing will suffice to separate the different clauses (i.e. parts) of the `SELECT` statement. ~~~~ Immediately following the `SELECT` keyword is a list of the columns that you want in the result. diff --git a/exercises/concept/intro-select/.meta/config.json b/exercises/concept/weather-report/.meta/config.json similarity index 77% rename from exercises/concept/intro-select/.meta/config.json rename to exercises/concept/weather-report/.meta/config.json index b824e6c9..674e9b7e 100644 --- a/exercises/concept/intro-select/.meta/config.json +++ b/exercises/concept/weather-report/.meta/config.json @@ -8,10 +8,10 @@ ], "files": { "solution": [ - "intro-select.sql" + "weather-report.sql" ], "test": [ - "intro-select_test.sql" + "weather-report_test.sql" ] }, "blurb": "Learn SELECT statement basics" diff --git a/exercises/concept/intro-select/.meta/design.md b/exercises/concept/weather-report/.meta/design.md similarity index 100% rename from exercises/concept/intro-select/.meta/design.md rename to exercises/concept/weather-report/.meta/design.md diff --git a/exercises/concept/intro-select/create_fixture.sql b/exercises/concept/weather-report/create_fixture.sql similarity index 100% rename from exercises/concept/intro-select/create_fixture.sql rename to exercises/concept/weather-report/create_fixture.sql diff --git a/exercises/concept/intro-select/data.csv b/exercises/concept/weather-report/data.csv similarity index 100% rename from exercises/concept/intro-select/data.csv rename to exercises/concept/weather-report/data.csv diff --git a/exercises/concept/intro-select/report-results b/exercises/concept/weather-report/report-results similarity index 100% rename from exercises/concept/intro-select/report-results rename to exercises/concept/weather-report/report-results diff --git a/exercises/concept/intro-select/test-result.jq b/exercises/concept/weather-report/test-result.jq similarity index 100% rename from exercises/concept/intro-select/test-result.jq rename to exercises/concept/weather-report/test-result.jq diff --git a/exercises/concept/intro-select/test_data.json b/exercises/concept/weather-report/test_data.json similarity index 100% rename from exercises/concept/intro-select/test_data.json rename to exercises/concept/weather-report/test_data.json diff --git a/exercises/concept/intro-select/intro-select.sql b/exercises/concept/weather-report/weather-report.sql similarity index 100% rename from exercises/concept/intro-select/intro-select.sql rename to exercises/concept/weather-report/weather-report.sql diff --git a/exercises/concept/intro-select/intro-select_test.sql b/exercises/concept/weather-report/weather-report_test.sql similarity index 89% rename from exercises/concept/intro-select/intro-select_test.sql rename to exercises/concept/weather-report/weather-report_test.sql index 6609a7cf..0951bc63 100644 --- a/exercises/concept/intro-select/intro-select_test.sql +++ b/exercises/concept/weather-report/weather-report_test.sql @@ -4,7 +4,7 @@ -- Run user solution and store results .mode markdown .output user_output.md -.read ./intro-select.sql +.read ./weather-report.sql .save ./results.db .output From 8ea434d3d586abf643972301d2e053c5271a3f48 Mon Sep 17 00:00:00 2001 From: Todd Schwartz Date: Fri, 19 Dec 2025 07:35:37 -0800 Subject: [PATCH 08/10] Replace humidity with wind_speed --- .../weather-report/.docs/instructions.md | 6 ++--- .../concept/weather-report/create_fixture.sql | 2 +- exercises/concept/weather-report/data.csv | 12 ++++----- .../concept/weather-report/test_data.json | 26 +++++++++---------- .../concept/weather-report/weather-report.sql | 4 +-- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/exercises/concept/weather-report/.docs/instructions.md b/exercises/concept/weather-report/.docs/instructions.md index 481ec555..9a7f1bc4 100644 --- a/exercises/concept/weather-report/.docs/instructions.md +++ b/exercises/concept/weather-report/.docs/instructions.md @@ -6,7 +6,7 @@ You will be working with a database containing a `weather_readings` table with t * `date`: The date on which the sample was collected. * `location`: The name of the city in which the sample was collected. * `temperature`: The temperature, in degrees Fahrenheit. -* `humidity`: The relative humidity, as a percentage value. +* `wind_speed`: The wind speed, in miles per hour. In each of the following tasks, your job is to retrieve the specified result set, by using a `SELECT` statement. Note that in each case, the result set will be stored in a new table -- one table for each task -- via a pre-written `CREATE TABLE` statement. @@ -25,6 +25,6 @@ Retrieve only the location and temperature values from the `weather_readings` ta Retrieve only the data for the Seattle location. -## 4. Retrieve only the data with humidity in a specific range +## 4. Retrieve only the data with wind speed in a specific range -Retrieve only the data where the humidity is between 60% and 70%. \ No newline at end of file +Retrieve only the data where the wind speed is between 5 and 15 miles per hour. \ No newline at end of file diff --git a/exercises/concept/weather-report/create_fixture.sql b/exercises/concept/weather-report/create_fixture.sql index c96de796..f13b663d 100644 --- a/exercises/concept/weather-report/create_fixture.sql +++ b/exercises/concept/weather-report/create_fixture.sql @@ -3,7 +3,7 @@ CREATE TABLE weather_readings ( date TEXT NOT NULL, location TEXT NOT NULL, temperature INTEGER NOT NULL, - humidity INTEGER NOT NULL + wind_speed INTEGER NOT NULL ); .mode csv diff --git a/exercises/concept/weather-report/data.csv b/exercises/concept/weather-report/data.csv index cbe5e09a..d01fb5e2 100644 --- a/exercises/concept/weather-report/data.csv +++ b/exercises/concept/weather-report/data.csv @@ -1,6 +1,6 @@ -"2025-10-22","Portland",53,72 -"2025-10-22","Seattle",56,66 -"2025-10-22","Boise",60,55 -"2025-10-23","Portland",54,70 -"2025-10-23","Seattle",57,68 -"2025-10-23","Boise",62,58 +"2025-10-22","Portland",53,19 +"2025-10-22","Seattle",56,5 +"2025-10-22","Boise",60,1 +"2025-10-23","Portland",54,11 +"2025-10-23","Seattle",57,6 +"2025-10-23","Boise",62,21 diff --git a/exercises/concept/weather-report/test_data.json b/exercises/concept/weather-report/test_data.json index 9e83ee9d..bf82133f 100644 --- a/exercises/concept/weather-report/test_data.json +++ b/exercises/concept/weather-report/test_data.json @@ -3,12 +3,12 @@ "task_id": 1, "description": "All data", "expected": [ - {"date": "2025-10-22", "location": "Portland", "temperature": 53, "humidity": 72}, - {"date": "2025-10-22", "location": "Seattle", "temperature": 56, "humidity": 66}, - {"date": "2025-10-22", "location": "Boise", "temperature": 60, "humidity": 55}, - {"date": "2025-10-23", "location": "Portland", "temperature": 54, "humidity": 70}, - {"date": "2025-10-23", "location": "Seattle", "temperature": 57, "humidity": 68}, - {"date": "2025-10-23", "location": "Boise", "temperature": 62, "humidity": 58} + {"date": "2025-10-22", "location": "Portland", "temperature": 53, "wind_speed": 19}, + {"date": "2025-10-22", "location": "Seattle", "temperature": 56, "wind_speed": 5}, + {"date": "2025-10-22", "location": "Boise", "temperature": 60, "wind_speed": 1}, + {"date": "2025-10-23", "location": "Portland", "temperature": 54, "wind_speed": 11}, + {"date": "2025-10-23", "location": "Seattle", "temperature": 57, "wind_speed": 6}, + {"date": "2025-10-23", "location": "Boise", "temperature": 62, "wind_speed": 21} ] }, "location_and_temperature": { @@ -27,17 +27,17 @@ "task_id": 3, "description": "Seattle only", "expected": [ - {"date": "2025-10-22", "location": "Seattle", "temperature": 56, "humidity": 66}, - {"date": "2025-10-23", "location": "Seattle", "temperature": 57, "humidity": 68} + {"date": "2025-10-22", "location": "Seattle", "temperature": 56, "wind_speed": 5}, + {"date": "2025-10-23", "location": "Seattle", "temperature": 57, "wind_speed": 6} ] }, - "limited_humidity": { + "limited_wind_speed": { "task_id": 4, - "description": "Humidity within range", + "description": "wind_speed within range", "expected": [ - {"date": "2025-10-22", "location": "Seattle", "temperature": 56, "humidity": 66}, - {"date": "2025-10-23", "location": "Portland", "temperature": 54, "humidity": 70}, - {"date": "2025-10-23", "location": "Seattle", "temperature": 57, "humidity": 68} + {"date": "2025-10-22", "location": "Seattle", "temperature": 56, "wind_speed": 5}, + {"date": "2025-10-23", "location": "Portland", "temperature": 54, "wind_speed": 11}, + {"date": "2025-10-23", "location": "Seattle", "temperature": 57, "wind_speed": 6} ] } } diff --git a/exercises/concept/weather-report/weather-report.sql b/exercises/concept/weather-report/weather-report.sql index b76ba979..5fc7f875 100644 --- a/exercises/concept/weather-report/weather-report.sql +++ b/exercises/concept/weather-report/weather-report.sql @@ -13,7 +13,7 @@ CREATE TABLE seattle AS SELECT "TODO: Replace this SELECT statement as needed to accomplish the task" ; -CREATE TABLE limited_humidity AS - -- Task 4. Select all data where the humidity is between 60% and 70%. +CREATE TABLE limited_wind_speed AS + -- Task 4. Select all data where the wind speed is between 5 and 15 miles per hour. SELECT "TODO: Replace this SELECT statement as needed to accomplish the task" ; From b2e2313729e0162f73d6a5727bdbd263ab2846d8 Mon Sep 17 00:00:00 2001 From: Todd Schwartz Date: Fri, 19 Dec 2025 07:42:48 -0800 Subject: [PATCH 09/10] Add exemplar --- .../concept/weather-report/.meta/config.json | 3 +++ .../concept/weather-report/.meta/exemplar.sql | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 exercises/concept/weather-report/.meta/exemplar.sql diff --git a/exercises/concept/weather-report/.meta/config.json b/exercises/concept/weather-report/.meta/config.json index 674e9b7e..bffa305b 100644 --- a/exercises/concept/weather-report/.meta/config.json +++ b/exercises/concept/weather-report/.meta/config.json @@ -7,6 +7,9 @@ "jimmytty" ], "files": { + "exemplar": [ + ".meta/exemplar.sql" + ], "solution": [ "weather-report.sql" ], diff --git a/exercises/concept/weather-report/.meta/exemplar.sql b/exercises/concept/weather-report/.meta/exemplar.sql new file mode 100644 index 00000000..f652fe5e --- /dev/null +++ b/exercises/concept/weather-report/.meta/exemplar.sql @@ -0,0 +1,21 @@ +CREATE TABLE all_data AS + -- Task 1. Select all records. + SELECT * FROM weather_readings +; + +CREATE TABLE location_and_temperature AS + -- Task 2. Select only location and temperature data. + SELECT location, temperature FROM weather_readings +; + +CREATE TABLE seattle AS + -- Task 3. Select all data for Seattle. + SELECT * FROM weather_readings + WHERE location = "Seattle" +; + +CREATE TABLE limited_wind_speed AS + -- Task 4. Select all data where the wind speed is between 5 and 15 miles per hour. + SELECT * FROM weather_readings + WHERE wind_speed BETWEEN 5 AND 15 +; From 42e44c8941c3317b8c234e55d6f82e188bab5bc6 Mon Sep 17 00:00:00 2001 From: Todd Schwartz Date: Mon, 22 Dec 2025 16:59:06 -0800 Subject: [PATCH 10/10] Fix typo --- exercises/concept/weather-report/.meta/design.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/concept/weather-report/.meta/design.md b/exercises/concept/weather-report/.meta/design.md index 9c755b9e..6f995495 100644 --- a/exercises/concept/weather-report/.meta/design.md +++ b/exercises/concept/weather-report/.meta/design.md @@ -13,7 +13,7 @@ The goal of this exercise is to teach students the basics of the `SELECT` statem ## Out of scope - Advanced filtering -` Subqueries +- Subqueries ## Concepts