如何以水平方式在一个coloumn中显示数据? [英] how to display data in one coloumn in horizontal manner?
问题描述
我是来自apllication开发的新窗口。我尝试使用枢轴。但我没有得到可以解雇我。在这下面的链接告诉我只有特定年份。但是我希望在水晶报告中有不同的年份。
i有这样的表:
创建表学生(studentid int主键不为null,名称varchar(10),类varchar(10)..所以在不同的coloumns我被创建了)
创建表studentreport(studentid int,date datetime,score varchar(10))
表1:
学生ID名称等......所以
1 x 5
2年6月
3 z 7th
4 a 8th ...等等
表2:
studentid日期分数
1 2-6-2012 40
2 5-7-2012 30
3 4-8-2012 35
1 4-6-2013 12
1 6-8-2013 23
2 4- 7-2103 40
注意:像这样,每年都插入表中。这应该在水晶报告中按升序排列
就像我想要这样的报告如下所示
studentid:1名称:x class:5th
---------- -------------------------------------------------- ------------------------------
月2012 2013
得分得分
40 12
i是创建参数,上半部分工作意味着studentid,class, name.but问题低于报告中显示的问题我无法以横向显示多年来帮助那个人。我的报告就像一个单独的报告我想要生成plz帮助我.plz我帮我
感谢提前
声明 @ year varchar (max)= ' '
SELECT
@ year = Stuff(( SELECT ' ,[' + cast(s as varchar (max))+ ' ]'
FROM
( SELECT DISTINCT DATEPART(YYYY,Sdate) as s FROM dbo.StudDet
)x
对于 XML PATH(' ')), 1 , 1 ,' ')
exec (' select Months,' + @ year + ' < span class =code-string>
from
(
select cast(DATEPART(MONTH,Sdate)as varchar(max))as Months,Score,
DATEPART(year ,sdate)作为st
来自dbo.StudDet
)x
pivot
(
max(得分)
for st in(' + @ year + ' )
)p')
hi,i am new ti c# windows from apllication development . i was tried using pivot .but i am not getting can hepl me . in this below link tells that only paticular year. but i want to disaply different years in crystal report .
i have tables like this :
create table student(studentid int primary key not null,name varchar(10),class varchar(10)..so on diffrent coloumns i was created )
create table studentreport(studentid int,date datetime,score varchar(10))
table 1 :
student id name class ...... so on
1 x 5th
2 y 6th
3 z 7th
4 a 8th... so on
table 2:
studentid date score
1 2-6-2012 40
2 5-7-2012 30
3 4-8-2012 35
1 4-6-2013 12
1 6-8-2013 23
2 4-7-2103 40
note :like this when ever year was insert into table .that should be upadate in crystal report in ascending order
like i want report like this seen below
studentid:1 name: x class :5th
------------------------------------------------------------------------------------------
month 2012 2013
score score
40 12
23
i was create parameter that is working for upper part means studentid ,class,name.but problem is below one shown in report i cant able to display years in horizontall manner aleast help that one. my report this like a indiviual report i wnt to genrate plz help me .plz hepl me
thanks advance
Declare @year varchar(max)='' SELECT @year= Stuff((SELECT ', [' + cast(s as varchar(max))+']' FROM (SELECT DISTINCT DATEPART(YYYY,Sdate) as s FROM dbo.StudDet ) x For XML PATH ('')),1,1,'') exec('select Months,'+@year+' from ( select cast(DATEPART(MONTH,Sdate) as varchar(max)) as Months,Score, DATEPART(year,Sdate) as st from dbo.StudDet ) x pivot ( max(Score) for st in('+@year+') )p ')
这篇关于如何以水平方式在一个coloumn中显示数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!