Perfect. Thanks a lot PHV.
I also added in the following so that the query doesn't return a record where none of the conditions are met.
WHERE (PI_EXPIRY_DATE<>0) OR (WC_expiry_date<>0) OR (EL_expiry_date<>0) OR (CAR_expiry_date<>0);
Apologies, there was an error in my original description of the problem. It should have said:
... Among the columns are four columns that hold the expiry dates for different types of insurance. I need to write a query that counts the number of these columns, within each record, where the date...
Thanks PHV.
This is what the SQL statement looks like in my DB:
SELECT Company_name, Count(*) AS NumOfExpiry
FROM Company
WHERE PI_EXPIRY_DATE<Now()+60 OR WC_expiry_date<Now()+60 OR EL_expiry_date<Now()+60 OR CAR_expiry_date<Now()+60
GROUP BY Company_name
It runs and returns the company name...
I have a table with a large number of columns. Among the columns are four columns that hold the expiry dates for different types of insurance. I need to write a query that counts the number of records, where the date difference on any of the four columns, between the date now and the expiry...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.