【发布时间】:2021-12-02 13:15:01
【问题描述】:
我已经创建了两个表,现在我想找到为每个平台(Hulu、迪士尼和 Netflix)带来最高收入的电影。这里的问题是我不知道如何输出平台的名称,因为它是一个列标题。谁能帮帮我?
CREATE TABLE "StreamedMovies" (
"Title" TEXT,
"Netflix" INTEGER, -- 1 if the movie is streamed in this platform, 0 otherwise
"Hulu" INTEGER, -- 1 if the movie is streamed in this platform, 0 otherwise
"Disney" INTEGER, -- 1 if the movie is streamed in this platform, 0 otherwise
"ScreenTime" REAL,
PRIMARY KEY("Title")
)
CREATE TABLE "MovieData" (
"Title" TEXT,
"Genre" TEXT,
"Director" TEXT,
"Casting" TEXT,
"Rating" REAL,
"Revenue" REAL,
PRIMARY KEY("Title")
)
【问题讨论】:
-
糟糕的设计会导致复杂的查询和糟糕的性能。更改数据库的设计。您只需要 1 列而不是 3 列(如果您想包含更多平台,则需要更多列)。