{ "data": { "question": { "questionId": "3488", "questionFrontendId": "3182", "boundTopicId": null, "title": "Find Top Scoring Students", "titleSlug": "find-top-scoring-students", "content": null, "translatedTitle": null, "translatedContent": null, "isPaidOnly": true, "difficulty": "Medium", "likes": 4, "dislikes": 2, "isLiked": null, "similarQuestions": "[]", "exampleTestcases": "{\"headers\":{\"students\":[\"student_id\",\"name\",\"major\"],\"courses\":[\"course_id\",\"name\",\"credits\",\"major\"],\"enrollments\":[\"student_id\",\"course_id\",\"semester\",\"grade\"]},\"rows\":{\"students\":[[1,\"Alice\",\"Computer Science\"],[2,\"Bob\",\"Computer Science\"],[3,\"Charlie\",\"Mathematics\"],[4,\"David\",\"Mathematics\"]],\"courses\":[[101,\"Algorithms\",3,\"Computer Science\"],[102,\"Data Structures\",3,\"Computer Science\"],[103,\"Calculus\",4,\"Mathematics\"],[104,\"Linear Algebra\",4,\"Mathematics\"]],\"enrollments\":[[1,101,\"Fall 2023\",\"A\"],[1,102,\"Fall 2023\",\"A\"],[2,101,\"Fall 2023\",\"B\"],[2,102,\"Fall 2023\",\"A\"],[3,103,\"Fall 2023\",\"A\"],[3,104,\"Fall 2023\",\"A\"],[4,103,\"Fall 2023\",\"A\"],[4,104,\"Fall 2023\",\"B\"]]}}", "categoryTitle": "Database", "contributors": [], "topicTags": [ { "name": "Database", "slug": "database", "translatedName": null, "__typename": "TopicTagNode" } ], "companyTagStats": null, "codeSnippets": null, "stats": "{\"totalAccepted\": \"298\", \"totalSubmission\": \"531\", \"totalAcceptedRaw\": 298, \"totalSubmissionRaw\": 531, \"acRate\": \"56.1%\"}", "hints": [], "solution": null, "status": null, "sampleTestCase": "{\"headers\":{\"students\":[\"student_id\",\"name\",\"major\"],\"courses\":[\"course_id\",\"name\",\"credits\",\"major\"],\"enrollments\":[\"student_id\",\"course_id\",\"semester\",\"grade\"]},\"rows\":{\"students\":[[1,\"Alice\",\"Computer Science\"],[2,\"Bob\",\"Computer Science\"],[3,\"Charlie\",\"Mathematics\"],[4,\"David\",\"Mathematics\"]],\"courses\":[[101,\"Algorithms\",3,\"Computer Science\"],[102,\"Data Structures\",3,\"Computer Science\"],[103,\"Calculus\",4,\"Mathematics\"],[104,\"Linear Algebra\",4,\"Mathematics\"]],\"enrollments\":[[1,101,\"Fall 2023\",\"A\"],[1,102,\"Fall 2023\",\"A\"],[2,101,\"Fall 2023\",\"B\"],[2,102,\"Fall 2023\",\"A\"],[3,103,\"Fall 2023\",\"A\"],[3,104,\"Fall 2023\",\"A\"],[4,103,\"Fall 2023\",\"A\"],[4,104,\"Fall 2023\",\"B\"]]}}", "metaData": "{\"mysql\": [\"CREATE TABLE if not exists students (\\n student_id INT ,\\n name VARCHAR(255),\\n major VARCHAR(255)\\n)\", \"CREATE TABLE if not exists courses (\\n course_id INT ,\\n name VARCHAR(255),\\n credits INT,\\n major VARCHAR(255)\\n)\\n\", \"CREATE TABLE if not exists enrollments (\\n student_id INT,\\n course_id INT,\\n semester VARCHAR(255),\\n grade VARCHAR(10)\\n\\n);\"], \"mssql\": [\"CREATE TABLE students (\\n student_id INT ,\\n name VARCHAR(255),\\n major VARCHAR(255)\\n)\", \"CREATE TABLE courses (\\n course_id INT ,\\n name VARCHAR(255),\\n credits INT,\\n major VARCHAR(255)\\n)\\n\", \"CREATE TABLE enrollments (\\n student_id INT,\\n course_id INT,\\n semester VARCHAR(255),\\n grade VARCHAR(10)\\n\\n);\"], \"oraclesql\": [\"CREATE TABLE students (\\n student_id NUMBER ,\\n name VARCHAR2(255),\\n major VARCHAR2(255)\\n)\", \"CREATE TABLE courses (\\n course_id NUMBER,\\n name VARCHAR2(255),\\n credits NUMBER,\\n major VARCHAR2(255)\\n)\", \"CREATE TABLE enrollments (\\n student_id NUMBER,\\n course_id NUMBER,\\n semester VARCHAR2(255),\\n grade VARCHAR2(10) \\n \\n)\"], \"database\": true, \"name\": \"find_top_scoring_students\", \"pythondata\": [\"enrollments = pd.DataFrame([], columns=['student_id', 'course_id', 'semester', 'grade']).astype({\\n 'student_id': 'Int64', # Nullable integer type\\n 'course_id': 'Int64', # Nullable integer type\\n 'semester': 'object', # Object type for arbitrary strings\\n 'grade': 'object' # Object type for arbitrary strings\\n})\", \"students = pd.DataFrame([], columns=['student_id', 'name', 'major']).astype({\\n 'student_id': 'Int64', # Nullable integer type\\n 'name': 'object', # Object type for arbitrary strings, equivalent to VARCHAR\\n 'major': 'object' # Object type for arbitrary strings, equivalent to VARCHAR\\n})\", \"courses = pd.DataFrame([], columns=['course_id', 'name', 'credits', 'major']).astype({\\n 'course_id': 'Int64', # Nullable integer type\\n 'name': 'object', # Object type for arbitrary strings, equivalent to VARCHAR\\n 'credits': 'Int64', # Nullable integer type\\n 'major': 'object' # Object type for arbitrary strings, equivalent to VARCHAR\\n})\"], \"postgresql\": [\"CREATE TABLE IF NOT EXISTS students (\\n student_id INT,\\n name VARCHAR(255),\\n major VARCHAR(255)\\n);\\n\", \"CREATE TABLE IF NOT EXISTS courses (\\n course_id INT,\\n name VARCHAR(255),\\n credits INT,\\n major VARCHAR(255)\\n);\\n\", \"CREATE TABLE IF NOT EXISTS enrollments (\\n student_id INT,\\n course_id INT,\\n semester VARCHAR(255),\\n grade VARCHAR(10)\\n);\\n\"], \"database_schema\": {\"students\": {\"student_id\": \"INT\", \"name\": \"VARCHAR(255)\", \"major\": \"VARCHAR(255)\"}, \"courses\": {\"course_id\": \"INT\", \"name\": \"VARCHAR(255)\", \"credits\": \"INT\", \"major\": \"VARCHAR(255)\"}, \"enrollments\": {\"student_id\": \"INT\", \"course_id\": \"INT\", \"semester\": \"VARCHAR(255)\", \"grade\": \"VARCHAR(10)\"}}}", "judgerAvailable": true, "judgeType": "large", "mysqlSchemas": [ "CREATE TABLE if not exists students (\n student_id INT ,\n name VARCHAR(255),\n major VARCHAR(255)\n)", "CREATE TABLE if not exists courses (\n course_id INT ,\n name VARCHAR(255),\n credits INT,\n major VARCHAR(255)\n)\n", "CREATE TABLE if not exists enrollments (\n student_id INT,\n course_id INT,\n semester VARCHAR(255),\n grade VARCHAR(10)\n\n);", "Truncate table students", "insert into students (student_id, name, major) values ('1', 'Alice', 'Computer Science')", "insert into students (student_id, name, major) values ('2', 'Bob', 'Computer Science')", "insert into students (student_id, name, major) values ('3', 'Charlie', 'Mathematics')", "insert into students (student_id, name, major) values ('4', 'David', 'Mathematics')", "Truncate table courses", "insert into courses (course_id, name, credits, major) values ('101', 'Algorithms', '3', 'Computer Science')", "insert into courses (course_id, name, credits, major) values ('102', 'Data Structures', '3', 'Computer Science')", "insert into courses (course_id, name, credits, major) values ('103', 'Calculus', '4', 'Mathematics')", "insert into courses (course_id, name, credits, major) values ('104', 'Linear Algebra', '4', 'Mathematics')", "Truncate table enrollments", "insert into enrollments (student_id, course_id, semester, grade) values ('1', '101', 'Fall 2023', 'A')", "insert into enrollments (student_id, course_id, semester, grade) values ('1', '102', 'Fall 2023', 'A')", "insert into enrollments (student_id, course_id, semester, grade) values ('2', '101', 'Fall 2023', 'B')", "insert into enrollments (student_id, course_id, semester, grade) values ('2', '102', 'Fall 2023', 'A')", "insert into enrollments (student_id, course_id, semester, grade) values ('3', '103', 'Fall 2023', 'A')", "insert into enrollments (student_id, course_id, semester, grade) values ('3', '104', 'Fall 2023', 'A')", "insert into enrollments (student_id, course_id, semester, grade) values ('4', '103', 'Fall 2023', 'A')", "insert into enrollments (student_id, course_id, semester, grade) values ('4', '104', 'Fall 2023', 'B')" ], "enableRunCode": true, "enableTestMode": false, "enableDebugger": false, "envInfo": "{\"mysql\": [\"MySQL\", \"
MySQL 8.0
.
mssql server 2019
.
Oracle Sql 11.2
.
Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0
\"], \"postgresql\": [\"PostgreSQL\", \"PostgreSQL 16
\"]}", "libraryUrl": null, "adminUrl": null, "challengeQuestion": null, "__typename": "QuestionNode" } } }