{ "data": { "question": { "questionId": "1136", "questionFrontendId": "1050", "categoryTitle": "Database", "boundTopicId": 6075, "title": "Actors and Directors Who Cooperated At Least Three Times", "titleSlug": "actors-and-directors-who-cooperated-at-least-three-times", "content": "
Table: ActorDirector
\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| actor_id | int |\n| director_id | int |\n| timestamp | int |\n+-------------+---------+\ntimestamp is the primary key column for this table.\n\n\n
\n\n
Write a SQL query for a report that provides the pairs (actor_id, director_id)
where the actor has cooperated with the director at least three times.
Return the result table in any order.
\n\nThe query result format is in the following example.
\n\n\n
Example 1:
\n\n\nInput: \nActorDirector table:\n+-------------+-------------+-------------+\n| actor_id | director_id | timestamp |\n+-------------+-------------+-------------+\n| 1 | 1 | 0 |\n| 1 | 1 | 1 |\n| 1 | 1 | 2 |\n| 1 | 2 | 3 |\n| 1 | 2 | 4 |\n| 2 | 1 | 5 |\n| 2 | 1 | 6 |\n+-------------+-------------+-------------+\nOutput: \n+-------------+-------------+\n| actor_id | director_id |\n+-------------+-------------+\n| 1 | 1 |\n+-------------+-------------+\nExplanation: The only pair is (1, 1) where they cooperated exactly 3 times.\n\n", "translatedTitle": "合作过至少三次的演员和导演", "translatedContent": "
ActorDirector
表:
\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| actor_id | int |\n| director_id | int |\n| timestamp | int |\n+-------------+---------+\ntimestamp 是这张表的主键.\n\n\n
\n\n
写一条SQL查询语句获取合作过至少三次的演员和导演的 id 对 (actor_id, director_id)
示例:
\n\n\nActorDirector 表:\n+-------------+-------------+-------------+\n| actor_id | director_id | timestamp |\n+-------------+-------------+-------------+\n| 1 | 1 | 0 |\n| 1 | 1 | 1 |\n| 1 | 1 | 2 |\n| 1 | 2 | 3 |\n| 1 | 2 | 4 |\n| 2 | 1 | 5 |\n| 2 | 1 | 6 |\n+-------------+-------------+-------------+\n\nResult 表:\n+-------------+-------------+\n| actor_id | director_id |\n+-------------+-------------+\n| 1 | 1 |\n+-------------+-------------+\n唯一的 id 对是 (1, 1),他们恰好合作了 3 次。\n", "isPaidOnly": false, "difficulty": "Easy", "likes": 31, "dislikes": 0, "isLiked": null, "similarQuestions": "[]", "contributors": [], "langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", "topicTags": [ { "name": "Database", "slug": "database", "translatedName": "数据库", "__typename": "TopicTagNode" } ], "companyTagStats": null, "codeSnippets": [ { "lang": "MySQL", "langSlug": "mysql", "code": "# Write your MySQL query statement below", "__typename": "CodeSnippetNode" }, { "lang": "MS SQL Server", "langSlug": "mssql", "code": "/* Write your T-SQL query statement below */", "__typename": "CodeSnippetNode" }, { "lang": "Oracle", "langSlug": "oraclesql", "code": "/* Write your PL/SQL query statement below */", "__typename": "CodeSnippetNode" } ], "stats": "{\"totalAccepted\": \"18.4K\", \"totalSubmission\": \"24K\", \"totalAcceptedRaw\": 18425, \"totalSubmissionRaw\": 23981, \"acRate\": \"76.8%\"}", "hints": [], "solution": null, "status": null, "sampleTestCase": "{\"headers\":{\"ActorDirector\":[\"actor_id\",\"director_id\",\"timestamp\"]},\"rows\":{\"ActorDirector\":[[1,1,0],[1,1,1],[1,1,2],[1,2,3],[1,2,4],[2,1,5],[2,1,6]]}}", "metaData": "{\n \"mysql\": [\n \"Create table If Not Exists ActorDirector (actor_id int, director_id int, timestamp int)\"\n ],\n \"mssql\": [\n \"Create table ActorDirector (actor_id int, director_id int, timestamp int)\"\n ],\n \"oraclesql\": [\n \"Create table ActorDirector (actor_id int, director_id int, timestamp int)\"\n ],\n \"database\": true\n}", "judgerAvailable": true, "judgeType": "large", "mysqlSchemas": [ "Create table If Not Exists ActorDirector (actor_id int, director_id int, timestamp int)", "Truncate table ActorDirector", "insert into ActorDirector (actor_id, director_id, timestamp) values ('1', '1', '0')", "insert into ActorDirector (actor_id, director_id, timestamp) values ('1', '1', '1')", "insert into ActorDirector (actor_id, director_id, timestamp) values ('1', '1', '2')", "insert into ActorDirector (actor_id, director_id, timestamp) values ('1', '2', '3')", "insert into ActorDirector (actor_id, director_id, timestamp) values ('1', '2', '4')", "insert into ActorDirector (actor_id, director_id, timestamp) values ('2', '1', '5')", "insert into ActorDirector (actor_id, director_id, timestamp) values ('2', '1', '6')" ], "enableRunCode": true, "envInfo": "{\"mysql\":[\"MySQL\",\"
\\u7248\\u672c\\uff1a mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\" Oracle Sql 11.2.<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"ActorDirector\":[\"actor_id\",\"director_id\",\"timestamp\"]},\"rows\":{\"ActorDirector\":[[1,1,0],[1,1,1],[1,1,2],[1,2,3],[1,2,4],[2,1,5],[2,1,6]]}}",
"__typename": "QuestionNode"
}
}
}MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"