Browse Source

SQL Wiz

master
Chris Yealy 11 months ago
parent
commit
ba0738830f
1 changed files with 25 additions and 3 deletions
  1. +25
    -3
      02-sql/SQL Wizard.ipynb

+ 25
- 3
02-sql/SQL Wizard.ipynb View File

@ -76,7 +76,7 @@
"\n", "\n",
"SQL queries are made of individual statements. These statements start with a word which specifies what you'd like to do, such as `SELECT` to retrieve data, `UPDATE` to update existing rows, and `DELETE` to delete records from the database. Let's practice a SELECT statement.\n", "SQL queries are made of individual statements. These statements start with a word which specifies what you'd like to do, such as `SELECT` to retrieve data, `UPDATE` to update existing rows, and `DELETE` to delete records from the database. Let's practice a SELECT statement.\n",
"\n", "\n",
"The syntax of `SELECT` is as follows: `SELECT <the names of columns I would like returned separated by commas> FROM <table name>;`. SQL also has a shorthand for selecting all columns: `SELECT * FROM <table name>;;`\n",
"The syntax of `SELECT` is as follows: `SELECT <the names of columns I would like returned separated by commas> FROM <table name>`. SQL also has a shorthand for selecting all columns: `SELECT * FROM <table name>`\n",
"\n", "\n",
"One last thing before we dive in! To make a Jupyter notebook cell run SQL, you must start the cell with `%%sql`. Without this, you'll likely get some errors since Jupyter will try to run it as SQL code. I will include this for you to make your life easier but you should know why it's there :)\n", "One last thing before we dive in! To make a Jupyter notebook cell run SQL, you must start the cell with `%%sql`. Without this, you'll likely get some errors since Jupyter will try to run it as SQL code. I will include this for you to make your life easier but you should know why it's there :)\n",
"\n", "\n",
@ -97,11 +97,33 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "cf28b6f1-c215-405c-afbf-c65cac1c2b7c", "id": "cf28b6f1-c215-405c-afbf-c65cac1c2b7c",
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [], "outputs": [],
"source": [ "source": [
"%%sql\n", "%%sql\n",
"SELECT * from all_railey_properties"
"# Add your select statement here"
]
},
{
"cell_type": "markdown",
"id": "6f2fc505-8403-401e-b409-c9dacfc40911",
"metadata": {},
"source": [
"You'll notice that for your display convenience only ten results are displayed to you. Still, this query does select every row, but it would flood the notebook with results if it return all 500+ so the software doesn't allow that by default."
]
},
{
"cell_type": "markdown",
"id": "b36ab734-88f9-4db5-8a92-2d6d990362c9",
"metadata": {},
"source": [
"## Basic SQL functions\n",
"\n",
"SQL comes with some functions which allow you to calculate various measures. The three we will look at are `COUNT`, `SUM`, and `AVG`.\n",
"\n",
"`COUNT` will return "
] ]
}, },
{ {

Loading…
Cancel
Save