纵表格式如图所示:sql
查询sql语句以下:spa
Select ID, Time,convert(varchar(8000),content)content,Date from SummerChina where countryID='86' and LineType='0'
变成横表如图所示:code
纵表变横表sql语句以下:blog
select Time, max(case Date when 'Morning' then content else null end) as Morning, max(case Date when 'Afternoon' then content else null end)as Afternoon from (Select ID, Time,convert(varchar(8000),content)content,Date from SummerChina where countryID='86' and LineType='0') as t group by Time