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
 General SQL Server Forums
 New to SQL Server Programming
 how to make query look better

Author  Topic 

jeff06
Posting Yak Master

166 Posts

Posted - 2007-08-28 : 11:40:39
select contractnbr,affcontractnbr,tdd,affrtramount,affturn,
pt=datediff(d,afffirstfundingdate,affRTRBalanceZeroDate),ratio=datediff(d,afffirstfundingdate,affRTRBalanceZeroDate)/afftrun
from #targetfinishedaff

datediff(d,afffirstfundingdate,affRTRBalanceZeroDate) appears two times in this code, Is there a way to make it appear only once?
Thx

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-08-28 : 11:48:45
You could turn it into a function or use a derived table, but that would just complicate things.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -