From 7c48caa87d5f2d6c550baec5186534c9ca88edf1 Mon Sep 17 00:00:00 2001 From: bot50 Date: Mon, 13 Apr 2026 15:01:22 +0000 Subject: [PATCH] daviddoji-cs50/problems/2024/sql/views@20260413T150122.959098220Z --- 1.sql | 3 +++ 10.sql | 5 +++++ 2.sql | 3 +++ 3.sql | 3 +++ 4.sql | 3 +++ 5.sql | 3 +++ 6.sql | 3 +++ 7.sql | 3 +++ 8.sql | 3 +++ 9.sql | 2 ++ 10 files changed, 31 insertions(+) create mode 100644 1.sql create mode 100644 10.sql create mode 100644 2.sql create mode 100644 3.sql create mode 100644 4.sql create mode 100644 5.sql create mode 100644 6.sql create mode 100644 7.sql create mode 100644 8.sql create mode 100644 9.sql diff --git a/1.sql b/1.sql new file mode 100644 index 0000000..7fd2559 --- /dev/null +++ b/1.sql @@ -0,0 +1,3 @@ +-- write a SQL query that a translator might take interest in: list, side by side, the Japanese title and the +-- English title for each print. Ensure the Japanese title is the first column, followed by the English title. +SELECT "japanese_title", "english_title" FROM "views"; diff --git a/10.sql b/10.sql new file mode 100644 index 0000000..f157615 --- /dev/null +++ b/10.sql @@ -0,0 +1,5 @@ +-- write a SQL query to answer a question of your choice about the prints. The query should: +-- Make use of AS to rename a column +-- Involve at least one condition, using WHERE +-- Sort by at least one column, using ORDER BY +SELECT ROUND(AVG("brightness"), 2) AS "Hiroshige Average Brightness" FROM "views" WHERE "artist" = "Hiroshige"; diff --git a/2.sql b/2.sql new file mode 100644 index 0000000..1873ad9 --- /dev/null +++ b/2.sql @@ -0,0 +1,3 @@ +-- write a SQL query to list the average colors of prints by Hokusai that include “river” in the English title. +-- (As an aside, do they have any hint of blue?) +SELECT "average_color" FROM "views" WHERE "artist" = "Hokusai" AND "english_title" LIKE "%river%"; diff --git a/3.sql b/3.sql new file mode 100644 index 0000000..ccc0230 --- /dev/null +++ b/3.sql @@ -0,0 +1,3 @@ +-- write a SQL query to count how many prints by Hokusai include “Fuji” in the English title. +-- Though all of Hokusai’s prints focused on Mt. Fuji, in how many did “Fuji” make it into the title? +SELECT COUNT(*) FROM "views" WHERE "artist" = "Hokusai" AND "english_title" LIKE "%Fuji%"; diff --git a/4.sql b/4.sql new file mode 100644 index 0000000..7116d98 --- /dev/null +++ b/4.sql @@ -0,0 +1,3 @@ +-- write a SQL query to count how many prints by Hiroshige have English titles that refer to the “Eastern Capital”. +-- Hiroshige’s prints were created in Japan’s “Edo period,” referencing the eastern capital city of Edo, now Tokyo. +SELECT COUNT(*) FROM "views" WHERE "artist" = "Hiroshige" AND "english_title" LIKE "%Eastern%Capital%"; diff --git a/5.sql b/5.sql new file mode 100644 index 0000000..ce88339 --- /dev/null +++ b/5.sql @@ -0,0 +1,3 @@ +-- write a SQL query to find the highest contrast value of prints by Hokusai. Name the column “Maximum Contrast”. +-- Does Hokusai’s prints most contrasting print actually have much contrast? +SELECT MAX("contrast") AS "Maximum Contrast" FROM "views"; diff --git a/6.sql b/6.sql new file mode 100644 index 0000000..d85cea3 --- /dev/null +++ b/6.sql @@ -0,0 +1,3 @@ +-- write a SQL query to find the average entropy of prints by Hiroshige, rounded to two decimal places. +-- Call the resulting column “Hiroshige Average Entropy”. +SELECT ROUND(AVG("entropy"), 2) AS "Hiroshige Average Entropy" FROM "views" WHERE "artist" = "Hiroshige"; diff --git a/7.sql b/7.sql new file mode 100644 index 0000000..5bf3830 --- /dev/null +++ b/7.sql @@ -0,0 +1,3 @@ +-- write a SQL query to list the English titles of the 5 brightest prints by Hiroshige, from most to least bright. +-- Compare them to this list on Wikipedia to see if your results match the print’s aesthetics. +SELECT "english_title" FROM "views" WHERE "artist" = "Hiroshige" ORDER BY "brightness" DESC LIMIT 5; diff --git a/8.sql b/8.sql new file mode 100644 index 0000000..a62b60c --- /dev/null +++ b/8.sql @@ -0,0 +1,3 @@ +-- write a SQL query to list the English titles of the 5 prints with the least contrast by Hokusai, from least to highest contrast. +-- Compare them to this list on Wikipedia to see if your results match the print’s aesthetics. +SELECT "english_title" FROM "views" WHERE "artist" = "Hokusai" ORDER BY "contrast" ASC LIMIT 5; diff --git a/9.sql b/9.sql new file mode 100644 index 0000000..88a1179 --- /dev/null +++ b/9.sql @@ -0,0 +1,2 @@ +-- write a SQL query to find the English title and artist of the print with the highest brightness. +SELECT "english_title", "artist" FROM "views" ORDER BY "brightness" DESC LIMIT 1;