1.
select a.intid as ID ,a.Strname as 姓名,b.Strcaption as 学历 ,c.Strcaption as 民族
from person a,  BaseCode b,BaseCode c
where a.Inteducationid=b.intid and a.Intnationid=c.intid

解决方案 »

  1.   

    create table student(姓名    varchar(10),        学科 varchar(10),           成绩 int) 
    insert into student values('张三' ,           '语文'    ,        85 )
    insert into student values('李四',            '语文'      ,      80 )
    insert into student values('张三' ,           '英语'    ,        85 )
    select  姓名,语文=(sum(case 学科 when '语文' then 成绩 else 0 end  )) ,英语=(sum(case 学科 when '英语' then 成绩 else 0 end  )),数学=(sum(case 学科 when '数学' then 成绩 else 0 end  )) 
    from student
    group by 姓名
      

  2.   

    一中有问题:
    如果:张三的学历为未知也就是
    表person中Inteducationid为空或不在表BaseCode字段Intid中 
    那就查不出这个结果
    而要求为插入未知