2013-05-14 471 views

回答

4

不是很清楚你想要做什麼,但你通常使用CASE語句來做這件事。 嘗試下面的代碼,看看這是否是你之後。

select case when start2 >= start1 
      and start2 <= end1 then start1 
           else start2 
     end as group_start 
     ,case when end2 >= end1 then end2 
           else end1 
     end as group_end 
    from ... 
1

希望這B:如果確定PLZ記得標記爲答案

declare @startDate date; 
declare @workingDays int; 

set @startDate=GETDATE(); 
set @workingDays=9; 


if ((DATEPART(DAY,@startDate)=15) AND (@workingDays=5)) 
    print('asif') 
    else if ((DATEPART(DAY,@startDate)=15) AND (@workingDays=9)) 
    print('mahamud') 
    else if ((@workingDays>5)) 
    print('nop') 
    else 
    print ('99')