parent
bf84b17f93
commit
4aa4eb8e63
@ -0,0 +1,108 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "bb4281ad",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Q1. all city names in the Cities table"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ccc16638-bad1-42e2-8004-f225c54cdcb5",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"SELECT city\\\n",
|
||||
"FROM Cities"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "dcf23339-e7dd-483b-a043-9bbce4a167d7",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Q2. all cities in Ireland in the Cities table"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "26fe320e-1d2d-423e-9fcc-9e3db643fa96",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"SELECT city\\\n",
|
||||
"FROM Cities\\\n",
|
||||
"WHERE country = 'Ireland'"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "3ca1a291-8adb-4c76-9bec-1d7a67d697da",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Q3. all airport names with their city and country"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "0aa54aed-c41f-41e8-ba3e-a99fc9992fb0",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"SELECT Airports.name, Cities.city, Cities.country\\\n",
|
||||
"FROM Airports\\\n",
|
||||
"INNER JOIN Cities\\\n",
|
||||
"ON Cities.id = Airports.city_id"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "e53bf50d-d4c3-4c1d-9a82-ad229e946bb4",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Q4. all airports in London, United Kingdom"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "99aca6e9-27c2-4422-be1b-4658e8309ac6",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"SELECT Airports.name\\\n",
|
||||
"FROM Airports\\\n",
|
||||
"INNER JOIN Cities\\\n",
|
||||
"ON Cities.id = Airports.city_id\\\n",
|
||||
"WHERE Cities.city = 'London'\\\n",
|
||||
"AND Cities.Country = 'United Kingdom',"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "81fa9a71-5bb2-4489-ad5e-fcdab7362ad2",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.13.4"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,134 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "82f08ef0",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Q1. List all the tables in the db"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "fd29416d-0221-4047-9b2d-4a012cd184c0",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"SELECT name\\\n",
|
||||
"FROM sqlite_master\\\n",
|
||||
"WHERE type='table'\\\n",
|
||||
"AND name\\\n",
|
||||
"NOT LIKE 'sqlite_%'"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "4ef19ecc-81f9-41f9-9889-914368a33d96",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"- dept\n",
|
||||
"- emp\n",
|
||||
"- proj"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "7b63ac95-7664-4dc5-88ac-f77935091fab",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Q2. dept table_info"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "2ca49b91-528b-4902-ad65-c3fc181faca7",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"PRAGMA table_info(dept)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "91fab8d2-ce8c-4651-af24-d93f1913783c",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Q3. emp table_info"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "5b0132dd-ba43-429e-acc9-f1a5ae7e2b1b",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"PRAGMA table_info(emp)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "f8b71a48-0a18-4197-aee5-f2d7f22d65a5",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Q4. proj table_info"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a966aa66-0f31-457f-a64e-854e894e9eed",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"PRAGMA table_info(proj)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "7d534edf-37b4-409a-b778-b9d0e9e67cd9",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Q5. Create a table with emp.ENAME, dept.DNAME, proj.PROJID, Managers.Manager"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "afa75542-3fdb-4c0f-bd92-3c8fbbdbb56c",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"SELECT emp.ENAME, dept.DNAME, proj.PROJID, Managers.Manager\\\n",
|
||||
"FROM dept\\\n",
|
||||
"INNER JOIN emp\\\n",
|
||||
" on dept.DEPTNO = emp.DEPTNO\\\n",
|
||||
"INNER JOIN proj\\\n",
|
||||
" ON emp.EMPNO = proj.EMPNO\\\n",
|
||||
"INNER JOIN Managers\\\n",
|
||||
" ON Managers.Employee = emp.ENAME"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "1514a0b2-97e6-4910-89a4-1292c4c24944",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.13.4"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
|
|
|
|
|
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
SELECT emp.ENAME, dept.DNAME, proj.PROJID, Managers.Manager
|
||||
FROM dept
|
||||
INNER JOIN emp
|
||||
on dept.DEPTNO = emp.DEPTNO
|
||||
INNER JOIN proj
|
||||
ON emp.EMPNO = proj.EMPNO
|
||||
INNER JOIN Managers
|
||||
ON Managers.Employee = emp.ENAME
|
||||
Binary file not shown.
Loading…
Reference in new issue