codice:select id,val,[Lunedì],[Martedì],[Mercoledì],[Giovedì],[Venerdì],[Sabato],[Domenica] from ( select id,'valore1' as val,giorno,valore1 as [valore] from tabella union all select id,'valore2',giorno,valore2 from tabella) as t1 pivot ( sum(valore) for [giorno] IN ([Lunedì],[Martedì],[Mercoledì],[Giovedì],[Venerdì],[Sabato],[Domenica]) ) as t2 group by id,[Lunedì],[Martedì],[Mercoledì],[Giovedì],[Venerdì],[Sabato],[Domenica],val order by id,val