首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

sql语句,Repeater数据显示有关问题

2013-02-04 
sql语句,Repeater数据显示问题[解决办法]哥们 你指定查找的是 李四这人的资料了 肯定就只有一条了 名字为

sql语句,Repeater数据显示问题

[解决办法]
哥们 你指定查找的是 李四这人的资料了 肯定就只有一条了 名字为李四的就只有一个
[解决办法]
with teacher(teacherId,teacherName)
as(
select 1,'李四' union all
select 2,'王五'),
student(studentId,studentName,teacherId)
as(
select 1,'学生1',1 union all
select 2,'学生2',1 union all
select 3,'学生3',1 union all
select 4,'学生4',2),
scores(scoreId,courseName,grade,level,studentId)
as(
select 1,'数学',80,2,1 union all
select 2,'英语',90,1,1 union all
select 3,'数学',95,1,1 union all
select 4,'英语',65,3,4)


select distinct  teacherName,studentName,
stuff((select '          '+scores from
(select courseName+stuff((select ','+rtrim(grade) from scores s3 where s2.studentid=s3.studentid and s3.courseName=s2.courseName for xml path('')),1,1,'')as scores from scores s2 where s2.studentid=s1.studentid group by s2.courseName,s2.studentId)t for xml path('')),
1,10,'')score,level from student stu1 left join teacher t1 on t1.teacherid=stu1.teacherid 
left join scores s1 on stu1.studentid=s1.studentid where t1.teachername='李四'

热点排行