发布网友 发布时间:2022-04-20 04:10
共2个回答
懂视网 时间:2022-04-08 15:09
TABLE [dbo].[EndLongChangeAcross]( [Id] [INT] IDENTITY(1,1) NOT NULL, [Name] [NVARCHAR](50) NOT NULL, [Chinese] [INT] NOT NULL, [English] [INT] NOT NULL, [Math] [INT] NOT NULL, CONSTRAINT [PK_EndLongChangeAcross] PRIMARY KEY CLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO ALTER TABLE [dbo].[EndLongChangeAcross] ADD CONSTRAINT [DF_EndLongChangeAcross_Chinese] DEFAULT ((0)) FOR [Chinese] GO ALTER TABLE [dbo].[EndLongChangeAcross] ADD CONSTRAINT [DF_EndLongChangeAcross_English] DEFAULT ((0)) FOR [English] GO ALTER TABLE [dbo].[EndLongChangeAcross] ADD CONSTRAINT [DF_EndLongChangeAcross_Math] DEFAULT ((0)) FOR [Math] GO2.具体SQL
SELECT Name , ‘语文‘ AS ‘Subject‘, Chinese AS ‘Score‘ FROM dbo.EndLongChangeAcross UNION ALL SELECT Name , ‘英语‘, English AS ‘Score‘ FROM dbo.EndLongChangeAcross UNION ALL SELECT Name , ‘数学‘ , Math AS ‘Score‘ FROM dbo.EndLongChangeAcross ORDER BY Name DESC
具体效果:
MSSQL纵列转横列
标签:
热心网友 时间:2022-04-08 12:17
打开Excel文件,鼠标拖动并选中横列数据,右击点击复制。
复制后横列数据显示选择状态。
2
然后鼠标放在竖列单元格中,如:A2单元格,后右击:“选择性粘贴”---“倒置”即可完成转换 哦。
END
竖列转横列
打开Excel文件,鼠标拖动并选中竖列数据,右击点击复制。
复制后竖列数据显示选择状态。
然后鼠标放在横列单元格中,后右击:“选择性粘贴”---“倒置”即可完成转换 哦。