Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Query optimization help urgent

Author  Topic 

sreenu9f
Yak Posting Veteran

73 Posts

Posted - 2010-10-08 : 09:18:14
Hi i have a query like this
SELECT left(AccountTypeID,1)as PtType,AccountTypeID,InsuranceID,Number,Balance,ArToBadDebtAmount
from vNWH_BarBadDebtBalAccounts join
(select Distinct BillingID from vNWH_BarArBalAccountDetails where SegmentDateTime IN (@StartAnalysisDate) group by BillingID Having Sum(Balance)> 0) vNWH_BarArBalAccountDetails on vNWH_BarArBalAccountDetails.BillingID = vNWH_BarBadDebtBalAccounts.BillingID
where (SegmentDateTime between dateadd(dd,1,@StartAnalysisDate) and @EndDate) and ArtoBadDebtAmount is not null


which is taking a lot of time to run. please suggest for any optimization.
basically there are two tables BarArBalAccountDetails and BarBadDebtAccounts. I would like to get the final output from BarBadDebtAccounts table for a specific billing id's from BarArBalAccountDetails table for a specific period and all the transactions for these billing ids in BarBadDebtAccounts table from 1 day after the specific date mentioned in the BarArBalAccountDetails table and a certain end date in BarBadDebtAccounts table.

Any help is greatly appreciated.

Thanks

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2010-10-08 : 10:42:41
posting
the (planned/actual) execution plan.
the volume of records in each table.
the DDL for the tables involved.
definition of "a lot of time" - one man's ferrari, is anothers ford fiesta
server/SAN specs.
all would help.
help us help you....etc, etc, etc.
Go to Top of Page

sreenu9f
Yak Posting Veteran

73 Posts

Posted - 2010-10-08 : 11:03:27
Thanks actually i had the wrong join. it is all fixed now.

sorry.. but thanks for the review and suggestions.

Go to Top of Page
   

- Advertisement -