{
    "data": {
        "question": {
            "questionId": "2041",
            "questionFrontendId": "1890",
            "boundTopicId": null,
            "title": "The Latest Login in 2020",
            "titleSlug": "the-latest-login-in-2020",
            "content": "<p>Table: <code>Logins</code></p>\n\n<pre>\n+----------------+----------+\n| Column Name    | Type     |\n+----------------+----------+\n| user_id        | int      |\n| time_stamp     | datetime |\n+----------------+----------+\n(user_id, time_stamp) is the primary key for this table.\nEach row contains information about the login time for the user with ID user_id.\n</pre>\n\n<p>&nbsp;</p>\n\n<p>Write an SQL query to report the <strong>latest</strong> login for all users in the year <code>2020</code>. Do <strong>not</strong> include the users who did not login in <code>2020</code>.</p>\n\n<p>Return the result table <strong>in any order</strong>.</p>\n\n<p>The query result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong>Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nLogins table:\n+---------+---------------------+\n| user_id | time_stamp          |\n+---------+---------------------+\n| 6       | 2020-06-30 15:06:07 |\n| 6       | 2021-04-21 14:06:06 |\n| 6       | 2019-03-07 00:18:15 |\n| 8       | 2020-02-01 05:10:53 |\n| 8       | 2020-12-30 00:46:50 |\n| 2       | 2020-01-16 02:49:50 |\n| 2       | 2019-08-25 07:59:08 |\n| 14      | 2019-07-14 09:00:00 |\n| 14      | 2021-01-06 11:59:59 |\n+---------+---------------------+\n<strong>Output:</strong> \n+---------+---------------------+\n| user_id | last_stamp          |\n+---------+---------------------+\n| 6       | 2020-06-30 15:06:07 |\n| 8       | 2020-12-30 00:46:50 |\n| 2       | 2020-01-16 02:49:50 |\n+---------+---------------------+\n<strong>Explanation:</strong> \nUser 6 logged into their account 3 times but only once in 2020, so we include this login in the result table.\nUser 8 logged into their account 2 times in 2020, once in February and once in December. We include only the latest one (December) in the result table.\nUser 2 logged into their account 2 times but only once in 2020, so we include this login in the result table.\nUser 14 did not login in 2020, so we do not include them in the result table.\n</pre>\n",
            "translatedTitle": null,
            "translatedContent": null,
            "isPaidOnly": false,
            "difficulty": "Easy",
            "likes": 34,
            "dislikes": 0,
            "isLiked": null,
            "similarQuestions": "[]",
            "exampleTestcases": "{\"headers\": {\"Logins\": [\"user_id\", \"time_stamp\"]}, \"rows\": {\"Logins\": [[6, \"2020-06-30 15:06:07\"], [6, \"2021-04-21 14:06:06\"], [6, \"2019-03-07 00:18:15\"], [8, \"2020-02-01 05:10:53\"], [8, \"2020-12-30 00:46:50\"], [2, \"2020-01-16 02:49:50\"], [2, \"2019-08-25 07:59:08\"], [14, \"2019-07-14 09:00:00\"], [14, \"2021-01-06 11:59:59\"]]}}",
            "categoryTitle": "Database",
            "contributors": [],
            "topicTags": [
                {
                    "name": "Database",
                    "slug": "database",
                    "translatedName": null,
                    "__typename": "TopicTagNode"
                }
            ],
            "companyTagStats": null,
            "codeSnippets": [
                {
                    "lang": "MySQL",
                    "langSlug": "mysql",
                    "code": "# Write your MySQL query statement below\n",
                    "__typename": "CodeSnippetNode"
                },
                {
                    "lang": "MS SQL Server",
                    "langSlug": "mssql",
                    "code": "/* Write your T-SQL query statement below */\n",
                    "__typename": "CodeSnippetNode"
                },
                {
                    "lang": "Oracle",
                    "langSlug": "oraclesql",
                    "code": "/* Write your PL/SQL query statement below */\n",
                    "__typename": "CodeSnippetNode"
                }
            ],
            "stats": "{\"totalAccepted\": \"6.7K\", \"totalSubmission\": \"8K\", \"totalAcceptedRaw\": 6710, \"totalSubmissionRaw\": 7981, \"acRate\": \"84.1%\"}",
            "hints": [],
            "solution": null,
            "status": null,
            "sampleTestCase": "{\"headers\": {\"Logins\": [\"user_id\", \"time_stamp\"]}, \"rows\": {\"Logins\": [[6, \"2020-06-30 15:06:07\"], [6, \"2021-04-21 14:06:06\"], [6, \"2019-03-07 00:18:15\"], [8, \"2020-02-01 05:10:53\"], [8, \"2020-12-30 00:46:50\"], [2, \"2020-01-16 02:49:50\"], [2, \"2019-08-25 07:59:08\"], [14, \"2019-07-14 09:00:00\"], [14, \"2021-01-06 11:59:59\"]]}}",
            "metaData": "{\n  \"mysql\": [\n    \"Create table If Not Exists Logins (user_id int, time_stamp datetime)\"\n  ],\n  \"mssql\": [\n    \"Create table Logins (user_id int, time_stamp datetime)\"\n  ],\n  \"oraclesql\": [\n    \"Create table Logins (user_id int, time_stamp date)\",\n    \"ALTER SESSION SET nls_date_format='YYYY-MM-DD HH24:MI:SS'\"\n  ],\n  \"database\": true\n}",
            "judgerAvailable": true,
            "judgeType": "large",
            "mysqlSchemas": [
                "Create table If Not Exists Logins (user_id int, time_stamp datetime)",
                "Truncate table Logins",
                "insert into Logins (user_id, time_stamp) values ('6', '2020-06-30 15:06:07')",
                "insert into Logins (user_id, time_stamp) values ('6', '2021-04-21 14:06:06')",
                "insert into Logins (user_id, time_stamp) values ('6', '2019-03-07 00:18:15')",
                "insert into Logins (user_id, time_stamp) values ('8', '2020-02-01 05:10:53')",
                "insert into Logins (user_id, time_stamp) values ('8', '2020-12-30 00:46:50')",
                "insert into Logins (user_id, time_stamp) values ('2', '2020-01-16 02:49:50')",
                "insert into Logins (user_id, time_stamp) values ('2', '2019-08-25 07:59:08')",
                "insert into Logins (user_id, time_stamp) values ('14', '2019-07-14 09:00:00')",
                "insert into Logins (user_id, time_stamp) values ('14', '2021-01-06 11:59:59')"
            ],
            "enableRunCode": true,
            "enableTestMode": false,
            "enableDebugger": false,
            "envInfo": "{\"mysql\": [\"MySQL\", \"<p><code>MySQL 8.0</code>.</p>\"], \"mssql\": [\"MS SQL Server\", \"<p><code>mssql server 2019</code>.</p>\"], \"oraclesql\": [\"Oracle\", \"<p><code>Oracle Sql 11.2</code>.</p>\"]}",
            "libraryUrl": null,
            "adminUrl": null,
            "challengeQuestion": null,
            "__typename": "QuestionNode"
        }
    }
}