Open JorgeMiguelGomes opened 4 months ago
Hi @Jorge,
This error could indicate a table is missing from the database or something similar, because the only scenario this error could arise is if the SQL query is unable to fetch something from the database (even if no data exists in the target tables, empty table would still work because the query would fetch the column names). Can you test the SQL Query below on the database itself and see if it works without returning an error?
WITH reset_counts_cte AS(
SELECT
work_email,
COUNT(id_request) AS resets_count
FROM password_reset_request WHERE admin_decision = 'Approved'
GROUP BY work_email
),
analytics_cte AS(
SELECT
pr.id_request,
pr.work_email,
vt.first_name,
vt.last_name,
vt.affiliation_name,
pr.request_date,
pr.reset_reason,
DATEDIFF(
pr.request_date,
LAG(pr.request_date) OVER (PARTITION BY pr.work_email ORDER BY pr.request_date)
) AS days_since_last_request,
COALESCE(rc.resets_count, 0) AS resets_count,
reset_completed
FROM
vetted_user AS vt
INNER JOIN
password_reset_request AS pr
ON pr.work_email = vt.work_email
LEFT JOIN reset_counts_cte AS rc
ON rc.work_email = vt.work_email
)
SELECT * FROM analytics_cte WHERE reset_completed = 0;
@tomahock can you please check? Thanks!
What happens
When clicking on "Password Reset" the following error is triggered