1.
select score from student_1 group by score having count(*) = 2

解决方案 »

  1.   

    1楼第一题和我一样
    第二题没有别的表和teachid关联怎么查到老师的名字啊,疑惑
    第3题不会
      

  2.   

    2、
    create table student_2(
    id int,
    teacherid int,
    student varchar(5),
    score int
    )
    insert into student_2
    select 1,1,'张三',90 union all
    select 2,2,'李四',80 union all
    select 3,3,'王五',85 union all
    select 4,1,'赵六',70goselect id,(case teacherid 
    when 1 then '王老师' 
    when 2 then '李老师' 
    when 3 then '赵老师' 
    else '' end) 教师姓名,student,score from student_2godrop table student_2
      

  3.   

    能问问=2是什么意思吗?我刚学ORACLE,count(*)是记录的条数吧?
      

  4.   

    三楼是按照MS SQLServer来写的,oracle不会~
      

  5.   

    如果有3个学生的分数一样的话呢
    写成count(*)>1会比较好吧
      

  6.   

    1,
    select score from student_1 group by score
    2,
    select id,
    老师姓名=case teacherid  
        when 1 then '王老师'  
        when 2 then '李老师'  
        when 3 then '赵老师'  
        else '' end ,
    student,score from student_2