唉!这个Sql语句应该不会很难吧(100分啦!!)
春节还要加班!昨天已经熬了一夜了,好烦哦,
各位大哥哥,快来帮帮我啊,偶快被老板炒鱿鱼了啊:(
有三个表:
第一个表:basicinfo
sid name
1 Jack
2 Tom
第二个表:grade1
sid course score
1 math 91
2 math 80
2 computer 80
第三个表:grade2
sid course score
1 english 93
我想通过Sql语句分别得到下面两个结果,这个sql语句该怎么写啊,烦死了!!
(关键是如何把表名grade1和grade2放在结果集里呀??)
sid name course grade score
1 Jack math grade1 91
1 Jack english grade2 93
sid name course grade score
2 Tom math grade1 80
2 Tom computer grade1 80
怎么办啊,都夜里两点啦,好困哦,帮帮我啦!!!!!!!!拜托啦!!
偶先呼呼了~~~~
------解决方案--------------------create table #tmpGrade(sid int, course varchar(10), grade varchar(10), score int)
insert into #tmpGrade select sid, course, 'grade1 ', score from grade1
insert into #tmpGrade select sid, course, 'grade2 ', score from grade2
select t1.sid, t1.[name], t2.course, t2.grade, t2.score
from basicin