I have this SQL code here..
SELECT cl.clientid,
cl.clientname,
cl.billingdate,
cp.startdate,
cp.expiration,
(SELECT COUNT(*)
FROM invoice
HERE client = cl.clientid) AS invoicecount
FROM client cl
INNER JOIN clientplan cp ON cp.client = cl.clientid
WHERE cl.isbilled = 1 AND expiration is NULL AND expiration > '2012-06-22'
My problem is that a client could have 3 client plans and they either have an expiration date or the expiration is NULL. I am trying to get the rows that are not expired or are NULL.
What am I doing wrong?
I’m not sure, but isn’t what you want this :
With an or instead of an and on the expirations. Because expiration cannot be null and > ‘2012-06-22’…