1、有一张表test,有3个字段id,name,parentid。parentid是指父亲的id,请写一个sql语句,找出当过爷爷的id和name。 
2、有一张学生表student,字段有student_id,name,即学号,名字。 
还有一张选课表,字段有student_id,lesson_id。 
还有一张课程表,字段lesson_id,lesson_name。 
学生和课程是多对多的关系。 写一个sql语句,找出所有选了全部课程的学生。 3、有一张表person表,字段有id,name,age。age是年龄。 
写一个sql语句,找出年龄最接近的2个人。 
如有下面4条记录: 
1,a,18 
2,b,20 
3,c,25 
4,d,26 
则输出3,4
4、问题描述:
已知关系模式:
S (SNO,SNAME) 学生关系。SNO 为学号,SNAME 为姓名
C (CNO,CNAME,CTEACHER) 课程关系。CNO 为课程号,CNAME 为课程名,CTEACHER 为任课教师
SC(SNO,CNO,SCGRADE) 选课关系。SCGRADE 为成绩
1. 找出没有选修过“李明”老师讲授课程的所有学生姓名
2. 列出有二门以上(含两门[color=#000080]
)不及格课程的学生姓名及其平均成绩本人初识oracle 问题多多还请各位大侠来解答?[/color]

解决方案 »

  1.   

    好吧,我先bai-google了再说!!
      

  2.   

    1.题
    select * from test1 c
    where exists(
    select 1 from test1 a
    where exists (select 1
    from test1 b where a.id1=b.parentid)
    and c.id1=a.parentid);
      

  3.   

    select * from test1 c
    where exists(
    select 1 from test1 a
    where exists (select 1
    from test1 b where a.id1=b.parentid)
    and c.id1=a.parentid);
      

  4.   

    1.题select * from test1 c
    where exists(
    select 1 from test1 a
    where exists (select 1
    from test1 b where a.id1=b.parentid)
    and c.id1=a.parentid);