sql server - How to make Query for that -


i have table structure there have make query in different way

table structure

  1. id unique identifier

  2. code varchar(5) not null

  3. recording_date datetime not null

  4. max_temp numeric(5,2) not null

  5. min_temp numeric(5,2) not null

we have data in table.we have data 2013 year , first 3 months. main thing have return's data in such format like

enter image description here

please me create query such logic.

thanks in advance.

presuming have 1 recording per day

select     datepart(m, month_start) + ' ' + datepart(yyyy, month_start)     , max_temp_days     , case         when denominator = 0 0         else (max_temp_days / denominator) * 100       end percent_max_temp_days     , min_temp_days     , case         when denominator = 0 0         else (min_temp_days / denominator) * 100       end percent_max_temp_days (     select          dateadd(month, datediff(month, 0, recording_date), 0) month_start         , sum(case when max_temp <= 0 1 end) max_temp_days         , sum(case when min_temp <= 0 1 end) min_temp_days         , count(*) denominator     temperaturerecordings     recording_date between '2013-01-01' , '2013-03-31'     group dateadd(month, datediff(month, 0, recording_date), 0) ) t order month_start 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -