SELECT f.card_serial_num, count(1) AS CardRxCnt
FROM [Excel 8.0;HDR=Yes;Database=C:\Users\Mike\Desktop\er.xls].[er$] AS f
WHERE f.location_name not like 'PREPACK'
and f.card_type not in ('PRN','sequential')
and (f.card_due_date = #9/15/2014# or f.card_due_date = #10/1/2014#)
GROUP BY f.card_serial_num
HAVING CardRxCnt >2
I have a problem with HAVING CardRxCnt >2
. If I take out, I get my query returned.
But if I have it in, it somehow prompts for an input and so when I just put 1 it
returns nothing. Actually without CardRxCnt
, sometimes the query prompts
for an input at which I enter 1 and the query executes. Yet other times it would just go through. So my question is two part:
what could be causing this random behavior of "asking"? I know to prompt for a user input, I have to surround a value with []. Could it be the Excel part?
CardRxCnt
(inSELECT
andHAVING
): I don't see what's wrong with it but when I add this, query does not work.
Please help. And I can't do VBA/macro here so if you're gonna say why don't you query with VBA it's not a solution for me.