We have a staging table (DB2) that receives production numbers on a daily basis from our plant.
Because of the occasional network outage, there may be days we receive no data. I am trying to create a sql query to retrieve the days but it is not working out
SELECT MODDATE,
COUNT(DISTINCT EWDF) AS COUNT
FROM PROD_FACT
WHERE MODDATE=CURRENT_DATE - 7 DAYS
GROUP BY MODDATE
HAVING COUNT(DISTINCT EWDF)=0
I was expecting something like this
MODDATE COUNT
---------- -----------
09/30/2011 0
1 record(s) selected.
but to no avail. I get no rows returned. What am I missing??
You probably need to have a sub query and use a not in.
Perhaps something like this: