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)
 Wher am I going wrong

Author  Topic 

mole999
Starting Member

49 Posts

Posted - 2014-10-01 : 14:02:35
I have a 900 line sql and whilst this should be in my mind very simple I cannot get this to work

What I want
When
RTC.shift_times is blank
Then
RTC.time_1 should be made blank in the query (currently it causes me a negative calculation elsewhere inlater processing .i.e i can't use a collision time without a duty start time)

tried

case When RTC.shift_times is null then RTC.time_1 else RTC.time_1 end As RTC_Time2


case When RTC.shift_times = '' then replace(RTC.time_1,'%','') else RTC.time_1 end As RTC_Time


case(RTC.shift_times) when null then replace(RTC.time_1,'%','') else RTC.time_1 end as RTC_Time






Mole

mole999
Starting Member

49 Posts

Posted - 2014-10-01 : 14:20:30
case when RTC.shift_times = '' then '' else RTC.time_1 end as RTC_Time,

seems to fit my needs

Mole
Go to Top of Page
   

- Advertisement -