The below example query takes a long time to run. I believe it will work better if I change the where in (Select) statement part to instead be a from table join. But I do not know how to write the SQL statement.
The below example query looks to see what customer_ID is not in both the Savings and Checking Table. I am looking for customers that have a savings account but do not have a checking account and are over the age 18.
Can someone let me know if I can rewrite the SQL statement to run more efficiently?
SELECT Saving.*
FROM Saving
where Saving.customer_id not in
(select customer_id from Checking)
AND DATEDIFF(month, cfmr_birthdate, getdate()) >= 216
--Age 18
Thanks,
The below example query looks to see what customer_ID is not in both the Savings and Checking Table. I am looking for customers that have a savings account but do not have a checking account and are over the age 18.
Can someone let me know if I can rewrite the SQL statement to run more efficiently?
SELECT Saving.*
FROM Saving
where Saving.customer_id not in
(select customer_id from Checking)
AND DATEDIFF(month, cfmr_birthdate, getdate()) >= 216
--Age 18
Thanks,