PSACCESSLOG - Need a SQL query that will provide distinct logins per day

16 Views Asked by At

PSACCESSLOG - I need a SQL query that will provide distinct logins per day.

I am struggling with the date time formats and grouping by day.

This is my current query

SELECT  
    CAST(LOGINDTTM AS date) AS "Date", 
    COUNT(DISTINCT OPRID) AS NumOPRs
FROM
    PSACCESSLOG  A
WHERE 
    TO_CHAR(((A.LOGINDTTM ) + ( 0)),'YYYY-MM-DD') >= '2024-03-01'
GROUP BY
    CAST(LOGINDTTM AS date)
ORDER BY 
    "Date"

This query results in many entries under the date 2024-03-01. I am looking for a total number for that date. Not sure what I am doing wrong

0

There are 0 best solutions below