纵表格式如图所示:
查询sql语句如下:
Select ID, Time,convert(varchar(8000),content)content,Date from SummerChina where countryID='86' and LineType='0'
变成横表如图所示:
纵表变横表sql语句如下:
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