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 2008 Forums
 Transact-SQL (2008)
 Running Current Balance in sql query

Author  Topic 

vsc33
Starting Member

3 Posts

Posted - 2013-12-10 : 09:24:28
I want output of running current balance of a particular ID through sql query.

I am able to achieve it through CTE in just 6 seconds for around 900 rows.

But once I add left join to the select statement its taking 45 seconds.

Thanks for your suggestion in advance.

Shruti

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2013-12-17 : 06:01:52
You can persist the cte result in a temp table.
And then make the join from the temp table.



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-12-17 : 07:46:45
quote:
Originally posted by vsc33

I want output of running current balance of a particular ID through sql query.

I am able to achieve it through CTE in just 6 seconds for around 900 rows.

But once I add left join to the select statement its taking 45 seconds.

Thanks for your suggestion in advance.

Shruti


see scenario 1
http://visakhm.blogspot.in/2010/01/multipurpose-apply-operator.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -