sql server pivot
程序员文章站
2023-11-15 13:04:16
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[YearSalary]( [year] [int] NULL, [salary] [money] NULL ) ON [PRIMARY] GO select * ... ......
set ansi_nulls on go set quoted_identifier on go create table [dbo].[yearsalary]( [year] [int] null, [salary] [money] null ) on [primary] go select * from yearsalary; select 'year' as workyear,[2011],[2012],[2013],[2014],[2015],[2016],[2017],[2018],[2019] from ( select year,salary from yearsalary) as sourcetable pivot ( avg(salary) for year in([2011],[2012],[2013],[2014],[2015],[2016],[2017],[2018],[2019]) ) as pivottable
上一篇: 深入理解jquery中的each用法
下一篇: python实现websocket服务器