Skip to content

Bug Report for sql-the-latest-login-in-2020 #5554

@jpcompartir

Description

@jpcompartir

Bug Report for https://neetcode.io/problems/sql-the-latest-login-in-2020

The question states that time_stamp will be a datetime object, and as the runner is postrgresql, EXTRACT(YEAR from...) should work?

Query:

SELECT user_id, MAX(time_stamp) AS last_stamp
FROM logins
WHERE EXTRACT(YEAR from time_stamp) = 2020
GROUP BY user_id

Error:

Error
function pg_catalog.extract(unknown, character varying) does not exist

Accepted Solution:

SELECT user_id, MAX(time_stamp) AS last_stamp
FROM logins
WHERE time_stamp >= '2020-01-01' AND time_stamp < '2021-01-01'
GROUP BY user_id

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions