北大“數(shù)據(jù)庫原理”上機(jī)實(shí)踐題目總結(jié)(2)

字號:

答案:4_1
    clear
    set talk off
    use s
    list off
    ?
    ?
    average age for sex=“w” to a
    ?“女生平均年齡:”
    ??str(a)
    ??“歲”
    set talk on
    return
    答案:4_2(需另建一個臨時表:cc.dbf 屬性為: cname ,sum,cxi )
    clear 例如: 高數(shù) 1 物理
    set talk off
    use cc
    index on teacher to liu
    total on teacher to yu fields 課程數(shù)
    use yu
    list off
    ?
    use cc
    sum 課程數(shù) to a
    ?“課程總數(shù):”
    ?? str(a)
    答案:4_3
    clear
    set talk off
    select sname,cname,grade;
    from s,sc,c1;
    where s.sno=sc.sno and c1.cno=sc.cno and c1.cno='1000';
    order by sc.grade desc
    set talk on
    答案:4_4
    clear
    set talk off
    select s.sno,s.sname,c1.cname,sc.grade;
    from s,c1,sc;
    where s.sno=sc.sno and c1.cno=sc.cno;
    and s.age in(select age;
    from s;
    where sname='古天樂')
    set talk on