Am I understanding this correctly?declare @hr table (EMPLOYEE_STATUS varchar(10), Status_Date datetime, Terminate_Date decimal)insert into @hr select 'Inactive', '2007-11-08', 0 union select 'Terminate', '2007-09-20', '20070920' union select 'Terminate', '2007-10-26', '20071026' union select 'Active', '2007-11-08', 0 union select 'Active', '2007-11-08', 0select [EMPLOYEE_STATUS], CASE WHEN [EMPLOYEE_STATUS]='Active' THEN DATEADD(day, 1, getdate()) WHEN [EMPLOYEE_STATUS]='Inactive' THEN DATEADD(day, 1, getdate()) WHEN [EMPLOYEE_STATUS]='Terminate' THEN( CONVERT( datetime, terminate_date, 110)) END AS [Status_Date]from (select Employee_Status [Employee_Status], Status_Date [StatusDate], cast(nullif(Terminate_date, '0') as varchar) [Terminate_date] from @hr ) dwhere terminate_date >=( CASE WHEN [EMPLOYEE_STATUS]='Terminate' THEN DATEADD(day,-30,GETDATE()) ELSE Terminate_date END) or terminate_date is null
edit: removed extra castNathan Skerl