The Latest Login in 2020
<p>Table: <code>Logins</code></p>

<pre>
+----------------+----------+
| Column Name    | Type     |
+----------------+----------+
| user_id        | int      |
| time_stamp     | datetime |
+----------------+----------+
(user_id, time_stamp) is the primary key (combination of columns with unique values) for this table.
Each row contains information about the login time for the user with ID user_id.
</pre>

<p>&nbsp;</p>

<p>Write a solution 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>

<p>Return the result table <strong>in any order</strong>.</p>

<p>The result format is in the following example.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> 
Logins table:
+---------+---------------------+
| user_id | time_stamp          |
+---------+---------------------+
| 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 |
+---------+---------------------+
<strong>Output:</strong> 
+---------+---------------------+
| user_id | last_stamp          |
+---------+---------------------+
| 6       | 2020-06-30 15:06:07 |
| 8       | 2020-12-30 00:46:50 |
| 2       | 2020-01-16 02:49:50 |
+---------+---------------------+
<strong>Explanation:</strong> 
User 6 logged into their account 3 times but only once in 2020, so we include this login in the result table.
User 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.
User 2 logged into their account 2 times but only once in 2020, so we include this login in the result table.
User 14 did not login in 2020, so we do not include them in the result table.
</pre>

[]
['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')"]
[{"value": "mysql", "text": "MySQL", "defaultCode": "# Write your MySQL query statement below\n"}, {"value": "mssql", "text": "MS SQL Server", "defaultCode": "/* Write your T-SQL query statement below */\n"}, {"value": "oraclesql", "text": "Oracle", "defaultCode": "/* Write your PL/SQL query statement below */\n"}, {"value": "pythondata", "text": "Pandas", "defaultCode": "import pandas as pd\n\ndef latest_login(logins: pd.DataFrame) -> pd.DataFrame:\n    "}, {"value": "postgresql", "text": "PostgreSQL", "defaultCode": "-- Write your PostgreSQL query statement below\n"}]
{"mysql": ["Create table If Not Exists Logins (user_id int, time_stamp datetime)"], "mssql": ["Create table Logins (user_id int, time_stamp datetime)"], "oraclesql": ["Create table Logins (user_id int, time_stamp date)", "ALTER SESSION SET nls_date_format='YYYY-MM-DD HH24:MI:SS'"], "database": true, "name": "latest_login", "pythondata": ["Logins = pd.DataFrame([], columns=['user_id', 'time_stamp']).astype({'user_id':'Int64', 'time_stamp':'datetime64[ns]'})"], "postgresql": ["Create table If Not Exists Logins (user_id int, time_stamp timestamp)"], "database_schema": {"Logins": {"user_id": "INT", "time_stamp": "DATETIME"}}}
{"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>"], "pythondata": ["Pandas", "<p>Python 3.10 with Pandas 2.2.2 and NumPy 1.26.4</p>"], "postgresql": ["PostgreSQL", "<p>PostgreSQL 16</p>"]}
['Database']