和mysql的一起对照着看:http://blog.csdn.net/rainyspring4540/article/details/50230259
这篇是oracle10g的环境
数据库结构如图:
这里将相同名字的不同分数(不同列)显示在多个行中,形如:
sql如下:
(select name ,'数学' as type ,math as score from student ) union (select name ,'语文' as type ,chinese as score from student ) union (select name ,'英语' as type ,english as score from student )
呵呵,原来 union和union All 是标准sql中的规范,所以和mysql的用法一样,sql server估计也一样,不过没测试过