Do you have an indexes on dtrs and cwhouse?
Check the Execution Plan in QA for that statement to see if it is using any indexes.
>I've got a query that takes an AWFULLY long time to run:
>
>
>SELECT citemno, SUM(ntrfqty2) AS Shipped
>FROM icitrf
>WHERE (dtrs BETWEEN '02/01/04' AND '03/26/04')
>AND (cwhouse BETWEEN 'WAL0000' AND 'WAL9999')
>GROUP BY citemno
>
>
>Any hints at how I might optimize this? I have created indices on the obvious fields (dtrs, cwhouse and citemno) but it still takes forever to run.
>
>Granted, I'm running it against a table of 4 million rows but it's only returning a couple hundred result records...
>
>TIA