One possible reason for not getting the results could be that the sales transactions in SALES_TRANS_ITEM_DLY, but their ITEM_ID doesn't exist in ITEM_DIM.
Your SQL query looks fine, the only problem seems to be the missing data in ITEM_DIM table.
The below mentioned query looks to be the equivalent sql query without subquery, and if you are getting some rows for this query then the subquery needs a review!
SELECT STID.SALES_TRANS_DATE
,STID.ITEM_ID
,STID.ITEM_QTY
FROM SALES_TRANS_ITEM_DLY AS STID
INNER JOIN ITEM_DIM B
ON A.ITEM_ID = B.ITEM_ID
WHERE STID.SALES_TRANS_DATE between '2011-01-01' and '2012-09-01'
AND B.DEPT_ID IN (4223)
AND B.FAMILY_GROUP_ID IN (124)
ORDER BY STID.SALES_TRANS_DT
↧