select
--startdate,enddate,datepart(MM,startdate),datepart(MM,enddate),enddate,
case
when (datepart(MM,startdate)<='1' and datepart(MM,enddate)>'1') then 1 else 0 end Jan,case
when (datepart(MM,startdate)<='2' and datepart(MM,enddate)>'2') then 1 else 0 end Feb,case
when (datepart(MM,startdate)<='3' and datepart(MM,enddate)>'3') then 1 else 0 end Mar,case
when (datepart(MM,startdate)<='4' and datepart(MM,enddate)>'4') then 1 else 0 end Apr,case
when (datepart(MM,startdate)<='5' and datepart(MM,enddate)>'5') then 1 else 0 end May,case
when (datepart(MM,startdate)<='6' and datepart(MM,enddate)>'6') then 1 else 0 end Jun,case
when (datepart(MM,startdate)>='1' and datepart(MM,enddate)>'7') then 1 else 0 end Jul,case
when (datepart(MM,startdate)>='1' and datepart(MM,enddate)>'8') then 1 else 0 end Aug,case
when (datepart(MM,startdate)>='1' and datepart(MM,enddate)>'9') then 1 else 0 end sep,case
when (datepart(MM,startdate)>='1' and datepart(MM,enddate)>'10') then 1 else 0 end Oct,case
when (datepart(MM,startdate)>='1' and datepart(MM,enddate)>'11') then 1 else 0 end Nov,case
when (datepart(MM,startdate)>='1' and datepart(MM,enddate)>'12') then 1 else 0 end Dec,*
from dbo.EmpNewwhere
emplno IN(101274,101429,101483,101513,101560,101592,101605)
No comments:
Post a Comment