1.创建对应的表
    create table student(
            `s#` int,
            sname varchar(32),
            sage int,
            ssex varchar
            )以下省略
    2.插入数据
    insert into student select 1,‘张三‘,18,‘男’ union all 
    select 2,‘李四‘,18,‘男’ union all ....
    3.查询“001”课程比“002”课程成绩高的所有学生的学号;
        select a.`s#‘ from sc a,sc b where a.`c#`=001 and b.`c#`=002 and a.score>b.score;

4.查询平均成绩大于60分的同学的学号和平均成绩; 
select `s#`,avg(score) from sc group by `s#` having avg(score)>60
原文地址:http://blog.51cto.com/12390959/2119089