| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 
 | create table #t 
(Ville varchar(30) not null,
Lu float NULL,
Ma float NULL,
Me float NULL,
Je float NULL,
Ve float NULL,
Sa float NULL,
Di float NULL)
 
insert into #t (Ville) select distinct Ville from TaVilles 
 
update #t set Lu = avg(T.temperature) from TaVilles V, TaTemperature T
where #t.Ville=V.Ville and V.villeid = T.villeid and datepart(w,T.Date) = 1
 
update #t set Ma = avg(T.temperature) from TaVilles V, TaTemperature T
where #t.Ville=V.Ville and V.villeid = T.villeid and datepart(w,T.Date) = 2
 
update #t set Me = avg(T.temperature) from TaVilles V, TaTemperature T
where #t.Ville=V.Ville and V.villeid = T.villeid and datepart(w,T.Date) = 3
 
update #t set Je = avg(T.temperature) from TaVilles V, TaTemperature T
where #t.Ville=V.Ville and V.villeid = T.villeid and datepart(w,T.Date) = 4
 
update #t set Ve = avg(T.temperature) from TaVilles V, TaTemperature T
where #t.Ville=V.Ville and V.villeid = T.villeid and datepart(w,T.Date) = 5
 
update #t set Sa = avg(T.temperature) from TaVilles V, TaTemperature T
where #t.Ville=V.Ville and V.villeid = T.villeid and datepart(w,T.Date) = 6
 
update #t set Di = avg(T.temperature) from TaVilles V, TaTemperature T
where #t.Ville=V.Ville and V.villeid = T.villeid and datepart(w,T.Date) = 7 | 
Partager