请“大力”,再看一下?

cryingboy 2003-04-07 04:12:04
还是刚才那个,只不过subject_table 有点变化
subject_Table
ClassID subID subName
A 1 englihs
A 2 C++
A 3 VC
B 1 ......

grade_table
studentID subID grade
A01 1 90
A01 2 70
A02 1 40
A02 2 70
..........
现知学生A01的班号是A,存储过程参数为:studentID,ClassID要得到如下结果
studentID subName grade
A01 english 90
A01 C++ 70
A01 VC 未录
...全文
9 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
pengdali 2003-04-07
CREATE PROCEDURe test
@studentID varchar(100),
@ClassID varchar(100)
as
select b.studentID,a.subName,isnull(cast(b.grade as varchar),'未录')
from subject_Table a left join grade_table b
on a.subID=b.subID where a.ClassID =@ClassID and b.studentID=@studentID
回复
happydreamer 2003-04-07
改一下
select b.studentID,a.subName,isnull(b.grade,'未录') grade
from subject_Table a left join grade_table
on a.subID =b.subID
回复
happydreamer 2003-04-07
select a.studentID,a.subName,isnull(b.grade, 未录) grade
from subject_Table a left join grade_table
on a.subID =b.subID
回复
cryingboy 2003-04-07
楼上的老师你的不对!
我根据“大力”上次的指教,自己做了一个结果是对了不知道是否规范
select b.studentID,a.subName,isnull(cast(b.grade as varchar),"未录") from Subject_table as a left join (select * from grade_table where studentID=@stucode) as b on a.SubjectID=b.subjectID where a.classID=@ClassCode
回复
caiyunxia 2003-04-07
CREATE PROCEDURe test
@studentID int,
@ClassID int
as
select a.studentID,subName, grade
from subject_Table a inner join grade_table b
on a.subID=b.subID where ClassID =@ClassID and a.studentID=@studentID
回复
相关推荐
发帖
疑难问题
创建于2007-09-28

2.1w+

社区成员

MS-SQL Server 疑难问题
申请成为版主
帖子事件
创建了帖子
2003-04-07 04:12
社区公告
暂无公告