I have read that the order in the WHERE statement does not matter, but I believe it might or I'm doing something wrong. I have about 50k records. I exported everything to Excel and filtered the report the same as the WHERE statement below and the totals do not match, by a lot!
Select myfield2, myfield2, myacc, mydate, mydte2,
ROW_NUMBER() OVER (Partition BY myacc, EXTRACT(YEAR FROM mydate),EXTRACT(MONTH FROM mydate) ORDER BY mydate) as RowN
FROM mytable
WHERE prod IN (1, 22, 3, 45, 354, 951, 10)
AND sta NOT IN ('LP','SOD')
AND mydte2 between 'yyyy/mm/dd' and 'yyyy/mm/dd'
Qualify ROW_NUMBER() OVER (Partition By myacc ORDER BY mydate) = 1;
The query runs, but the record count is too low. I built the WHERE statement piece by piece and I noticed that the NOT IN statement is what causing the issue.
What am I missing?