易截截图软件、单文件、免安装、纯绿色、仅160KB

SQl 数据合并,结果合并 - MS-SQL Server / 疑难问题

SQL code:
alter proc Sel_Stu_Soc
(
@Stu_Id int
)
as
select a.Stu_Id as 学号,a.Stu_Name as 姓名,a.Stu_Sex as 性别,b.Gr_Semester as 学期,
ISNULL((select b.Gr_Score where b.Gr_SubId=c.Su_Id and a.Stu_Id=b.Gr_StuId and c.Su_Id=1),0) as 语文,
ISNULL((select b.Gr_Score where b.Gr_SubId=c.Su_Id and a.Stu_Id=b.Gr_StuId and c.Su_Id=2),0) as 数学,
ISNULL((select b.Gr_Score where b.Gr_SubId=c.Su_Id and a.Stu_Id=b.Gr_StuId and c.Su_Id=3),0) as 英语
from Student as a
inner join
Grade as b
on a.Stu_Id=b.Gr_StuId
inner join
Subjects as c
on b.Gr_SubId=c.Su_Id
where Stu_Id=@Stu_Id

查询的结果execute Sel_Stu_Soc @Stu_Id=1
学号 姓名 性别 学期 语文 数学 英语
1 张三 男 2010 98 0 0
1 张三 男 2010 0 87 0
1 张三 男 2010 0 0 78

想要的结果显示
学号 姓名 性别 学期 语文 数学 英语
1 张三 男 2010 98 87 78


数据库结构:
Student:学生表
Stu_Id Stu_Name Stu_Sex
Grade: 成绩表
Gr_Semester Gr_StuId Gr_SubId Gr_Score
Subjects: 科目表
Su_Id Su_Name






SQL code:
alter proc Sel_Stu_Soc
(
@Stu_Id int
)
as
select a.Stu_Id a


相关问答:

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

sql小小的疑问 - .NET技术 / C#

可能因为工作的原因 接触数据库这块比较少,之前都是做程序这块,数据库这块都有专门的人来做 分工都很明细 所以对数据库这一块完全不了解。前段时间 去面试了几家公司 几乎都是在数据库这块挂掉的 连个简单的SQ ......

SQL如何优化问题 - MS-SQL Server / 疑难问题

今天做了一个存储过程   环境是SQL2000数据库  
大致如下
建立临时表
定义员工游标
        循环员工(属于1个公司)  
        ......

sql 问题 - MS-SQL Server / 基础类

需求如下:
学院 academy(aid,aname)
班级 class(cid,cname,aid)
学生 stu(sid,sname,aid,cid)
住宿区 region(rid,rname)
宿舍楼 build(bid,rid,bnote) bnote是‘男’/‘女’
宿舍 dorm(did,rid,bid,bedn ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号