晕倒.一条记录还用repeater啊.
取出来放在label上不行么?
取出来放在label上不行么?
解决方案 »
- winform实现窗体靠右边隐藏
- NHibernate我在调用session.CreateQuery时,报错“ExamClassDictTest is not mapped [from ...”
- 关于webbrowser 内容存入 sql数据库
- vs2005 express edition是不是试用版
- C#中一个string字符串最大能容纳多少字符?
- WinForm程序中怎样执行Url
- 多线程问题
- 如何刷新主窗口? 急啊——谁来救救我吧!
- 怎么使用控制台应用程序去时时监控数据库某一表是否有记录
- 在C#里如何使用Windows Media Player 9.0控件?(高分,高手入)
- 如何在基类中实现静态虚函数
- VS2005生成Web出现错误 详细如下
sql列转行
CREATE TABLE [Test] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[name] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[subject] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[Source] [numeric](18, 0) NULL
) ON [PRIMARY]
GO
INSERT INTO [test] ([name],[subject],[Source]) values (N'张三',N'语文',60)
INSERT INTO [test] ([name],[subject],[Source]) values (N'李四',N'数学',70)
INSERT INTO [test] ([name],[subject],[Source]) values (N'王五',N'英语',80)
INSERT INTO [test] ([name],[subject],[Source]) values (N'王五',N'数学',75)
INSERT INTO [test] ([name],[subject],[Source]) values (N'王五',N'语文',57)
INSERT INTO [test] ([name],[subject],[Source]) values (N'李四',N'语文',80)
INSERT INTO [test] ([name],[subject],[Source]) values (N'张三',N'英语',100)
Go--交叉表语句的实现:
--用于:交叉表的列数是确定的
select name,sum(case subject when '数学' then source else 0 end) as '数学',
sum(case subject when '英语' then source else 0 end) as '英语',
sum(case subject when '语文' then source else 0 end) as '语文'
from test
group by name--用于:交叉表的列数是不确定的
declare @sql varchar(8000)set @sql = 'select name,'
select @sql = @sql + 'sum(case subject when '''+subject+'''
then source else 0 end) as '''+subject+''','
from (select distinct subject from test) as a
select @sql = left(@sql,len(@sql)-1) + ' from test group by name'
exec(@sql)
go --用于:交叉表的列数是不确定的
declare @sql varchar(8000)
set @sql = 'select id,'
select @sql = @sql + '(case subject when '''+subject+'''
then source else null end) as '''+subject+''','
from (select distinct subject from test) as a
select @sql = left(@sql,len(@sql)-1) + ' from test '
exec(@sql)
go