Sasi Rekha

Sasi Rekha

  • NA
  • 507
  • 94.9k

Get halfyearly data from monthly data

May 24 2018 2:54 AM
How to get halfyearly data from monthly data
the structure isl ike below
I am having monthwise data i should convert it into halfyeardata with sum values''
Please tell me if anyone knows 
DS100  2018-01-01  100 
DS101 2018-02-01   100
 DS100  2018-07-01   100
DS100 2018-02-01 100 
 
I need like below result
 
DS100 Halfyear1  200   2018
DS100 Halfyear2   100   2018
DS101   Halfyear1  100   2018
 
Hi ,
 
i got answer myselg,please have a look
 
select DSID,Sum(IntValue),(datepart(mm,MONTH)-1)/6+1 as [halfyearly],datepart(yy,MONTH) as [year] from MonthlyData group by DSID,datepart(yy,MONTH),(datepart(mm,MONTH)-1)/6+1 
 

Answers (6)