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 2005 Forums
 Transact-SQL (2005)
 Query

Author  Topic 

legendmaddy
Starting Member

3 Posts

Posted - 2009-06-16 : 07:28:15
Hi All,
I did a query

Select A.G_L Account No_,B.Name as GLName,
sum(A.Amount) as Amount,
sum(A.Debit Amount) as Debit,
sum(A.Credit Amount) as Credit
from
European App1l$G_L Entry A,
European App2l$G_L Account B
where Account Type='0' and Income_Balance='0'
and A.Posting Date<='2009-01-01'
group by A.G_L Account No_,B.Name

this query takes just 15 seconds to retrive the data.

the same query bt only small difference insted of lessthan i use grater than condition

Select A.G_L Account No_,B.Name as GLName,
sum(A.Amount) as Amount,
sum(A.Debit Amount) as Debit,
sum(A.Credit Amount) as Credit
from
European Apparel$G_L Entry A,
European Apparel$G_L Account B
where Account Type='0' and Income_Balance='0'
and A.Posting Date>='2009-01-01'
group by A.G_L Account No_,B.Name

which should normally less data than the 1 st query ...but it taking lot of time to retrive data ..taking more than 1 hour.i would like to know the reason for that.can u please expalin me why is it like so??

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-16 : 07:31:45
It means you have probably have a different number of records satisfiying the two variants of WHERE.
It can also mean that the SQL engine has to create a execution plans for second query, if such does not exist.




E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -