Why do you JOIN on column "LoginTimestamp"? If LoginTimestamp changes the JOIN fails and returns the customer again; remove it.
left join to insert
arkiboys
9,686
Reputation points
hello,
I would like to return all rows from "Logins" which are not present in "tbl_LoginIdCount"
It's just that I run this once and insert into compute."tbl_LoginIdCount"
but then when I run the same query again the select still returns the same rows and does not see tha tthose rows are already in tbl_LoginIdCount
select
CURRENT_DATE , count(fl."LoginId"), fl."LatestCode"
from
"Logins" as fl
left join "tbl_LoginIdCount" as lc on date(fl."LoginTimestamp") = lc."Date" and fl."LatestCode" = lc."Code"
WHERE
lc."Date" is NULL and lc."Code" is null
group by
fl."LatestCode";