Skip to content

Commit

Permalink
feat (sql): taxi example update
Browse files Browse the repository at this point in the history
  • Loading branch information
santanche committed Sep 2, 2023
1 parent 160e903 commit fb77f7a
Showing 1 changed file with 115 additions and 11 deletions.
126 changes: 115 additions & 11 deletions sql/taxi/taxi01-sql-basico.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -448,13 +448,13 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "db021719-771b-4214-b8da-c89e4b83e905",
"model_id": "ef7975f5-524b-4b39-88d4-6b480c6ab51f",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -467,7 +467,7 @@
"source": [
"SELECT Nome\n",
" FROM Cliente\n",
" ORDER BY Nome;"
" ORDER BY Nome DESC;"
]
},
{
Expand Down Expand Up @@ -820,13 +820,13 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "edae2c6e-f7fe-40c0-a78f-d654e0198163",
"model_id": "bf886757-10eb-4743-b1d1-b4b33506be9c",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -853,13 +853,13 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "214902d4-26ad-4de5-8e32-21ef2a583a61",
"model_id": "9b1f868d-f82d-4f22-ae29-b1746721d217",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -891,13 +891,13 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "04eed808-0f4e-41cd-b623-314b756d0ff2",
"model_id": "c703a780-287f-4c70-8f77-63e0d53320ad",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -967,13 +967,13 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "afc5feab-35e3-485e-80e6-8be1f5562b0f",
"model_id": "bf598a87-db3c-476d-8733-170038021bf7",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -991,6 +991,110 @@
" GROUP BY Cl.Nome, T.Modelo;"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Contando Itens Distintos"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Quantos clientes distintos tomaram cada modelo de táxi"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c9d5a0ad-4e19-4f05-af98-2c1ff87b43a2",
"version_major": 2,
"version_minor": 0
},
"method": "display_data"
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"SELECT T.Modelo, Cl.Nome, COUNT(*)\n",
" FROM Cliente Cl, Corrida Co, Taxi T \n",
" WHERE Cl.CliId = Co.CliId AND \n",
" Co.Placa = T.Placa\n",
" GROUP BY T.Modelo, Cl.Nome;"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Sem distinguir clientes"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3f79acc3-a311-4f4c-a540-2d5d7f94d15b",
"version_major": 2,
"version_minor": 0
},
"method": "display_data"
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"SELECT T.Modelo, COUNT(*)\n",
" FROM Taxi T, Corrida Co\n",
" WHERE Co.Placa = T.Placa\n",
" GROUP BY T.Modelo;"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Com distinção de clientes"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "200d23e7-e3b1-4560-ae74-ca8b99e9dd98",
"version_major": 2,
"version_minor": 0
},
"method": "display_data"
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"SELECT T.Modelo, COUNT(DISTINCT Co.CliId)\n",
" FROM Taxi T, Corrida Co\n",
" WHERE Co.Placa = T.Placa\n",
" GROUP BY T.Modelo;"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit fb77f7a

Please sign in to comment.