|
-
Jul 2nd, 2002, 05:05 AM
#1
Thread Starter
Junior Member
3M records query timeout
I have an SQl Server 7.0 table with 3 million records this table is indexed on the ff. fields Terminal_Nb and Draw_Nb.
I need to run this query but always get timed out. Can you please help. How best to optimize the query. Thanks
Select distinct Terminal_No, Draw_nb,
(Select sum(Gross_Sales) from tickets where terminal_no = qrysales.Terminal_No and Draw_No = qrySales.Draw_Nb as Gross),
(Select sum(Gross_Sales) from tickets where terminal_no = qrysales.Terminal_No and Draw_No = qrySales.Draw_Nb and cancel_Date is not null as Cancels),
(Select sum(VAT) from tickets where terminal_no = qrysales.Terminal_No and Draw_No = qrySales.Draw_Nb as VATreturns),
(Select sum(Gross_Sales - VAT) from tickets where terminal_no = qrysales.Terminal_No and Draw_No = qrySales.Draw_Nb as ActualStake),
(Select sum(To_Pay) from tickets where terminal_no = qrysales.Terminal_No and Draw_No = qrySales.Draw_Nb and Payment_Date is not null as Payment)
from tickets qrySales
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|