标签:
declare @Subject table (--题目表变量 SubjectID int, Question nvarchar(MAX), CorrectAnswer varchar(100), Explain nvarchar(MAX), SubjectTypeID int, CreateID int, CreateDate datetime, SubjectScore decimal(3, 1), ScoreSort int ) insert into @Subject(SubjectID,Question,CorrectAnswer,Explain,SubjectTypeID,CreateID,CreateDate,SubjectScore,ScoreSort) select a.SubjectID,a.Question,a.CorrectAnswer,a.Explain,a.SubjectTypeID,a.CreateID,a.CreateDate,a.SubjectScore,a.ScoreSort from (--题目表(传入参数 HistPaperID,subjecttitleid) select a.SubjectID,Question,Answer as CorrectAnswer,Explain,TypeID as SubjectTypeID,a.CreateID,CreateDate,Score as SubjectScore,Sort as ScoreSort from HistPaperSubject a left join HistPaperSubjectScore b on a.subjectID=b.subjectID where a.isdel=0 and a.HistPaperID=60 and b.HistPaperID=60 and b.subjecttitleid=193) a select * from @Subject
标签:
原文地址:http://www.cnblogs.com/zhyue93/p/sql_1.html