Experiment 2 (SELECT - FILTER)
Experiment 2 (SELECT - FILTER)
Experiment 2 (SELECT - FILTER)
Out[1]:
Theodor-Heuss-
0 1 2 2009-01-01 Stuttgart None Germany 70174 1.98
Straße 34
... ... ... ... ... ... ... ... ... ...
319 N. Frances
407 408 25 2013-12-05 Madison WI USA 53703 3.96
Street
Rua dos
Campeões
409 410 35 2013-12-09 Porto None Portugal None 8.91
Europeus de
Viena, 4350
12,Community
411 412 58 2013-12-22 Delhi None India 110017 1.99
Centre
In [2]:
InvoiceDate BillingCountry
0 2009-01-01 Germany
1 2009-01-02 Norway
2 2009-01-03 Belgium
3 2009-01-06 Canada
4 2009-01-11 USA
In [3]:
df_3 = _deepnote_execute_sql('SELECT * FROM "Invoice" WHERE "BillingCountry" = \' Germany
\' ', 'SQL_5C2E9A9B_B591_4FC4_ADD5_829EB3188444')
df_3
Out[3]:
Theodor-Heuss-
0 1 2 2009-01-01 Stuttgart None Germany 70174 1.98
Straße 34
Barbarossastraße
2 7 38 2009-02-01 Berlin None Germany 10779 1.98
19
Theodor-Heuss-
3 12 2 2009-02-11 Stuttgart None Germany 70174 13.86
Straße 34
Barbarossastraße
5 30 38 2009-05-06 Berlin None Germany 10779 3.96
19
Barbarossastraße
7 52 38 2009-08-08 Berlin None Germany 10779 5.94
19
Theodor-Heuss-
8 67 2 2009-10-12 Stuttgart None Germany 70174 8.91
Straße 34
Barbarossastraße
10 104 38 2010-03-29 Berlin None Germany 10779 0.99
19
Theodor-Heuss-
14 196 2 2011-05-19 Stuttgart None Germany 70174 1.98
Straße 34
Theodor-Heuss-
15 219 2 2011-08-21 Stuttgart None Germany 70174 3.96
Straße 34
Barbarossastraße
17 225 38 2011-09-20 Berlin None Germany 10779 1.98
19
Barbarossastraße
18 236 38 2011-10-31 Berlin None Germany 10779 13.86
19
Theodor-Heuss-
19 241 2 2011-11-23 Stuttgart None Germany 70174 5.94
Straße 34
Barbarossastraße
22 291 38 2012-06-30 Berlin None Germany 10779 8.91
19
Theodor-Heuss-
23 293 2 2012-07-13 Stuttgart None Germany 70174 0.99
Straße 34
In [5]:
df_4 = _deepnote_execute_sql('SELECT COUNT(1) AS Jumlah FROM "Invoice" WHERE "BillingCoun
try" = \' Germany\' ', 'SQL_5C2E9A9B_B591_4FC4_ADD5_829EB3188444')
df_4
Out[5]:
jumlah
0 28
In [8]:
df_5 = _deepnote_execute_sql('SELECT DISTINCT("BillingCountry"), COUNT(1) AS "TotalBought
" \n FROM "Invoice"\n GROUP BY "BillingCountry"', 'SQL_5C2E9A9B_B591_4FC4_ADD5_829EB3188444
')
df_5
Out[8]:
BillingCountry TotalBought
0 Australia 7
1 Denmark 7
2 Netherlands 7
3 Belgium 7
4 India 13
5 Chile 7
6 Canada 56
7 Czech Republic 14
8 Norway 7
9 Sweden 7
10 United Kingdom 21
11 France 35
12 Spain 7
13 Argentina 7
14 Austria 7
15 Poland 7
16 Brazil 35
17 Italy 7
18 Hungary 7
19 Finland 7
20 Germany 28
21 Ireland 7
22 USA 91
23 Portugal 14
In [11]:
df_6 = _deepnote_execute_sql('SELECT DISTINCT("BillingCountry"), COUNT(1) AS "TotalBought
" \n FROM "Invoice"\n GROUP BY "BillingCountry"\n ORDER BY "TotalBought" DESC\n LIMIT 5', 'SQ
L_5C2E9A9B_B591_4FC4_ADD5_829EB3188444')
df_6
Out[11]:
BillingCountry TotalBought
0 USA 91
1 Canada 56
1 Canada 56
BillingCountry TotalBought
2 Brazil 35
3 France 35
4 Germany 28
In [15]:
df_7 = _deepnote_execute_sql('SELECT "BillingCountry", COUNT(1) FROM "Invoice" WHERE "Bil
lingCountry" = \' Sweden\' OR "BillingCountry" = \' France\' GROUP BY "BillingCountry"', '
SQL_5C2E9A9B_B591_4FC4_ADD5_829EB3188444')
df_7
Out[15]:
BillingCountry count
0 Sweden 7
1 France 35
In [16]:
df_8 = _deepnote_execute_sql('SELECT * FROM "Invoice"\n JOIN "Customer" ON "Customer"."Cus
tomerId" = "Invoice"."CustomerId"', 'SQL_5C2E9A9B_B591_4FC4_ADD5_829EB3188444')
df_8
Out[16]:
InvoiceId CustomerId InvoiceDate BillingAddress BillingCity BillingState BillingCountry BillingPostalCode Total CustomerId
Theodor-
0 1 2 2009-01-01 Heuss-Straße Stuttgart None Germany 70174 1.98
34
Ullevålsveien
1 2 4 2009-01-02 Oslo None Norway 0171 3.96
14
Grétrystraat
2 3 8 2009-01-03 Brussels None Belgium 1000 5.94
63
8210 111 ST
3 4 14 2009-01-06 Edmonton AB Canada T6G 2C7 8.91
NW
69 Salem
4 5 23 2009-01-11 Boston MA USA 2113 13.86
Street
... ... ... ... ... ... ... ... ... ...
319 N.
407 408 25 2013-12-05 Frances Madison WI USA 53703 3.96
Street
796 Dundas
408 409 29 2013-12-06 Toronto ON Canada M6J 1V1 5.94
Street West
Rua dos
Campeões
409 410 35 2013-12-09 Porto None Portugal None 8.91
Europeus de
Viena, 4350
Porthaninkatu
410 411 44 2013-12-14 Helsinki None Finland 00530 13.86
9
12,Community
411 412 58 2013-12-22 Delhi None India 110017 1.99
Centre
In [18]:
df_9 = _deepnote_execute_sql('SELECT "Invoice"."CustomerId", "FirstName", "LastName", "To
tal" FROM "Invoice"\n JOIN "Customer" ON "Customer"."CustomerId" = "Invoice"."CustomerId"'
, 'SQL_5C2E9A9B_B591_4FC4_ADD5_829EB3188444')
df_9
Out[18]:
In [21]:
df_10 = _deepnote_execute_sql('SELECT * FROM "Invoice" \n JOIN "Customer" ON "Invoice"."Cu
stomerId" = "Customer"."CustomerId"\n WHERE "Total" >= 10 \n ORDER BY "Total" DESC', 'SQL_5
C2E9A9B_B591_4FC4_ADD5_829EB3188444')
df_10
Out[21]:
InvoiceId CustomerId InvoiceDate BillingAddress BillingCity BillingState BillingCountry BillingPostalCode Total CustomerId
Czech
0 404 6 2013-11-13 Rilská 3174/6 Prague None 14300 25.86
Republic
3 Chatham
2 194 46 2011-04-28 Dublin Dublin Ireland None 21.86 46
Street
Erzsébet krt.
3 96 45 2010-02-18 Budapest None Hungary H-1073 21.86 45
58.
319 N.
4 201 25 2011-05-29 Frances Madison WI USA 53703 18.86 25
Street
... ... ... ... ... ... ... ... ... ... ...
194A Chain
59 376 31 2013-07-12 Halifax NS Canada B3S 1C5 13.86 31
Lake Drive
Rua Dr.
60 383 10 2013-08-12 Falcão Filho, São Paulo SP Brazil 01007-010 13.86 10
155
Salt Lake
61 311 28 2012-09-28 302 S 700 E UT USA 84102 11.94 28
City
Rua da
62 312 34 2012-10-01 Lisbon None Portugal None 10.91 34
Assunção 53
Assunção 53
InvoiceId CustomerId InvoiceDate BillingAddress BillingCity BillingState BillingCountry BillingPostalCode Total CustomerId
1 Microsoft
63 298 17 2012-07-31 Redmond WA USA 98052-8300 10.91 17
Way
64 rows × 22 columns
In [5]:
df_12 = _deepnote_execute_sql('SELECT * FROM "Artist" WHERE "Name" LIKE \' Led%\' ', 'SQL_
5C2E9A9B_B591_4FC4_ADD5_829EB3188444')
df_12
Out[5]:
ArtistId Name
0 22 Led Zeppelin
In [4]:
df_11 = _deepnote_execute_sql('SELECT * FROM "Artist" WHERE LOWER("Name") LIKE LOWER(\' L
ED%\' )', 'SQL_5C2E9A9B_B591_4FC4_ADD5_829EB3188444')
df_11
Out[4]:
ArtistId Name
0 22 Led Zeppelin
In [22]:
df_13 = _deepnote_execute_sql('SELECT "Artist"."Name", "Track"."Name" FROM "Artist"\n JOIN
"Album" ON "Album"."ArtistId" = "Artist"."ArtistId"\n JOIN "Track" ON "Track"."AlbumId" =
"Album"."AlbumId"\n WHERE UPPER("Artist"."Name") = UPPER(\' black sabbath\' )', 'SQL_5C2E9A
9B_B591_4FC4_ADD5_829EB3188444')
df_13
Out[22]:
Name Name
10 Black Sabbath FX
In [23]:
df_18 = _deepnote_execute_sql('SELECT "Artist"."Name", "Track"."Name" FROM "Artist"\n JOIN
"Album" ON "Album"."ArtistId" = "Artist"."ArtistId"\n JOIN "Track" ON "Track"."AlbumId" =
"Album"."AlbumId"\n WHERE UPPER("Artist"."Name") LIKE UPPER(\' %black%\' )', 'SQL_5C2E9A9B_
B591_4FC4_ADD5_829EB3188444')
df_18
Out[23]:
Name Name
28 Black Sabbath FX
28 Black Sabbath FX
Name Name
29 Black Sabbath Supernaut
INNER JOIN
In [26]:
df_17 = _deepnote_execute_sql('SELECT "cust"."name", "ords"."product" FROM "cust" \n JOIN
"ords" ON "cust"."id" = "ords"."cust_id"', 'SQL_5C2E9A9B_B591_4FC4_ADD5_829EB3188444')
df_17
Out[26]:
name product
0 A TV
1 A REMOTE
2 B BATU
3 D KUDA
4 E BONEKA
LEFT JOIN
In [29]:
df_18 = _deepnote_execute_sql('SELECT "cust"."name", "ords"."product" FROM "cust" \n LEFT
JOIN "ords" ON "cust"."id" = "ords"."cust_id"\n WHERE "ords"."id" IS NULL', 'SQL_5C2E9A9B_
B591_4FC4_ADD5_829EB3188444')
df_18
Out[29]:
name product
0 C None
RIGHT JOIN
In [31]:
df_19 = _deepnote_execute_sql('SELECT "cust"."name", "ords"."product" FROM "cust" \n RIGH
T JOIN "ords" ON "cust"."id" = "ords"."cust_id"', 'SQL_5C2E9A9B_B591_4FC4_ADD5_829EB31884
44')
df_19
Out[31]:
name product
0 A TV
1 A REMOTE
2 B BATU
3 D KUDA
4 E BONEKA
In [32]:
df_20 = _deepnote_execute_sql('SELECT "cust"."name", "ords"."product" FROM "cust" \n FULL
OUTER JOIN "ords" ON "cust"."id" = "ords"."cust_id"', 'SQL_5C2E9A9B_B591_4FC4_ADD5_829EB3
188444')
df_20
Out[32]:
name product
0 A TV
1 A REMOTE
2 B BATU
3 D KUDA
4 E BONEKA
5 C None
In [34]:
df_21 = _deepnote_execute_sql('SELECT "cust"."name", "ords"."product" FROM "cust" \n CROS
S JOIN "ords"', 'SQL_5C2E9A9B_B591_4FC4_ADD5_829EB3188444')
df_21
Out[34]:
name product
0 A TV
1 A REMOTE
2 A BATU
3 A KUDA
4 A BONEKA
5 name
B TV
product
6 B REMOTE
7 B BATU
8 B KUDA
9 B BONEKA
10 C TV
11 C REMOTE
12 C BATU
13 C KUDA
14 C BONEKA
15 D TV
16 D REMOTE
17 D BATU
18 D KUDA
19 D BONEKA
20 E TV
21 E REMOTE
22 E BATU
23 E KUDA
24 E BONEKA
IN
In [38]:
df_14 = _deepnote_execute_sql('SELECT * FROM "Artist" WHERE "Name" = \' AC/DC\' OR "Name"
= \' O Rappa\' OR "Name" = \' Kid Abelha\' ', 'SQL_5C2E9A9B_B591_4FC4_ADD5_829EB3188444')
df_14
Out[38]:
ArtistId Name
0 1 AC/DC
1 36 O Rappa
2 44 Kid Abelha
In [39]:
df_22 = _deepnote_execute_sql('SELECT * FROM "Artist" WHERE "Name" IN (\' AC/DC\' , \' O Ra
ppa\' , \' Kid Abelha\' )', 'SQL_5C2E9A9B_B591_4FC4_ADD5_829EB3188444')
df_22
Out[39]:
ArtistId Name
0 1 AC/DC
1 36 O Rappa
2 44 Kid Abelha
In [45]:
Out[45]:
Created in Deepnote