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)
 [Resolved] --- Sql Query calculate fields

Author  Topic 

rkalyani
Starting Member

30 Posts

Posted - 2009-07-01 : 14:19:32
I have a calcuated field in my query like this (Myfn.DateDiffWeekdays(dbo.startdate, dbo.endDate))as turnaround_time

Now I need to take this field and do a case on it. I am trying something like this
case when app_id = 0 then turnraound_time else '0' End as PaperTurnAroundTime

But I get an error
Invalid column name 'turnraound_time'.

Is there a way around this?


Thank you,
kal30

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-01 : 14:24:33
you can use it like this

SELECT other columns, case when app_id = 0 then turnraound_time else '0' End as PaperTurnAroundTime
FROM
(
Your current query with (Myfn.DateDiffWeekdays(dbo.startdate, dbo.endDate))as turnaround_time
)t

Go to Top of Page

rkalyani
Starting Member

30 Posts

Posted - 2009-07-01 : 15:42:19
Thank you. I was able to get it to work.

Thank you,
kal30
Go to Top of Page
   

- Advertisement -