Skip to content
Open

test #31

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
.ipynb_checkpoints
venv/
sql-part-2/studio/SQL Class 1 Studio.sql
71 changes: 63 additions & 8 deletions sql-part-1/exercises/SQL-Part-1-Exercises.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@
},
"outputs": [],
"source": [
"-- Code Here:"
"use BooksDB\n",
"select top 1000*\n",
"from weddings\n",
"\n"
]
},
{
Expand All @@ -88,7 +91,9 @@
},
"outputs": [],
"source": [
"-- Code Here:"
"use BooksDB\n",
"select 10000\n",
"from title\n"
]
},
{
Expand All @@ -108,7 +113,10 @@
},
"outputs": [],
"source": [
"-- Code Here:"
"use BooksDB\n",
"select original_publication_year\n",
"WHERE original_publication_year < 1800\n",
"\n"
]
},
{
Expand All @@ -127,9 +135,51 @@
}
},
"outputs": [],
"source": [
"-- Code Here:"
]
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "sql"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "sql"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "sql"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "sql"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
Expand All @@ -148,7 +198,10 @@
},
"outputs": [],
"source": [
"-- Code Here:"
"use BooksDB\n",
"select language_id\n",
"where language_id = \"eng\"\n",
"\n"
]
},
{
Expand All @@ -168,7 +221,9 @@
},
"outputs": [],
"source": [
"-- Code Here:"
"use BooksDB\n",
"select original_publication_year\n",
"where original_publication_year > 1914 and original_publication_year < 1921"
]
},
{
Expand Down
36 changes: 30 additions & 6 deletions sql-part-1/studio/SQL-Part-1-Studio.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@
},
"outputs": [],
"source": [
"-- return top 100 results"
"USE BooksDB \n",
"select TOP 100 book_id,authors,title,average_rating as \"rating\"\n",
"from dbo.books\n",
"order by average_rating desc\n",
"-- The Complete Calvin and Hobbes"
]
},
{
Expand All @@ -58,7 +62,11 @@
},
"outputs": [],
"source": [
"-- return least popular book"
"use BooksDB\n",
"select TOP 1 book_id,authors,title,average_rating\n",
"from dbo.books\n",
"order by average_rating\n",
"-- One Night at the Call Center"
]
},
{
Expand All @@ -78,7 +86,11 @@
},
"outputs": [],
"source": [
"-- return most popular tag"
"use BooksDB\n",
"SELECT TOP 1 tag_id, \"count\"\n",
"FROM BooksDB.dbo.book_tags\n",
"ORDER BY \"count\" DESC\n",
"-- 30574"
]
},
{
Expand All @@ -98,7 +110,11 @@
},
"outputs": [],
"source": [
"-- return name of most popular tag"
"use BooksDB\n",
"SELECT tag_id, tag_name\n",
"FROM BooksDB.dbo.tags\n",
"WHERE tag_id LIKE 30574\n",
"-- to-read"
]
},
{
Expand All @@ -118,7 +134,11 @@
},
"outputs": [],
"source": [
"-- return number of books published in the first decade of 2000"
"--use BooksDB\n",
"select count(*)\n",
"from dbo.books\n",
"where original_publication_year BETWEEN 2000 and 2010\n",
"-- 3594"
]
},
{
Expand All @@ -138,7 +158,11 @@
},
"outputs": [],
"source": [
"-- return number of books that contain the word, \"happy\""
"use BooksDB\n",
"select count(title)\n",
"from dbo.books\n",
"WHERE title LIKE '%Happy%';\n",
"--13"
]
},
{
Expand Down
Loading