Query runs all day

WSalaz01

New member
Local time
Today, 13:24
Joined
Jan 17, 2007
Messages
6
Dear pro,
I am having difficulties running a simple query that it runs all day and I have to kill it at the end of my date because it does not finish. Here is the statement that I would like some suggestions on how to improve it for faster results:
SELECT code, acct nbr, date, user, sum(amt)
FROM Tbl a
WHERE code IN
('AB',
'BC',
'CD',
'AA',
'BB',
'CC',
'ZZ'
)
AND date BETWEEN TO_DATE ('20070101', 'YYYYMMDD')
AND TO_DATE ('20070131', 'YYYYMMDD')
group by code,acc nbr,date,user

thank you...in advance for all your help..

Wilman.
 
Try changing:
Code:
AND date BETWEEN TO_DATE ('20070101', 'YYYYMMDD')
AND TO_DATE ('20070131', 'YYYYMMDD')
to...
Code:
AND [date] BETWEEN #01/01/2007# AND #01/31/2007#
...remember that date is a reserved word and should not be used as a name of a field. Maybe the brackets will work.
 

Users who are viewing this thread

Back
Top Bottom