实验目的
1.掌握SQL查询语句的一般格式
2.掌握简单数据查询操作
3.熟练掌握各种查询条件的表示
4.掌握排序和分组操作在SQL语句中的实现
5.掌握集函数的使用
实验内容和主要步骤:
第2题:
1>
SELECT
sname,
sno,
sdept
FROM
a.student;
2>
3>
SELECT * FROM a.sc;
select distinct sno from a.sc
4>
SELECT
sno
FROM
a.sc
WHERE
grade < 60
GROUP BY
sno;
5>
SELECT
sname, ssex
FROM
a.student
WHERE
not sdept = 'CS'
OR sdept = 'IS';
6>
select sno,grade from a.sc where cno=004 order by grade desc;
7>
select cno,count(cno)
from a.cs
group by cno;
好像出问题了……
8>
select sname,sage,sdept
from
a.student
where
sdept='cs'
9>
select
sno,sname,sage,sdept
from
a.student
where sage between 18 and 20;
10>
select*from
a.student
where sname like'liu%'
11>
select distinct sno
from a.sc
where cno='1'and sno
in(select distinct sno from a.sc where cno='2')
12>
SELECT Sname ,2003-Sage FROM a.student;
13>
select sno,
cno from a.sc where grade=0;
14>
select sno from a.sc
group by sno having sum(grade)>200;
15>
select cno,
count(distinct sno)
from a.sc
where grade<60 group by cno;
16>
select sname,avg(grade)
from a.sc,a.student
where a.student.sno=a.sc.sno and grade<60
group by sno
having by count(grade)>=3
报错了……
17>
select* from a.student where sage between 10 and 19;
18>
select* from a.student order by sdept asc,sage desc;
19>
select avg(grade) from a.sc where cno =001 group by cno;
20>
select max(grade)from a.sc where cno=003 group by cno;
21>
select sno,sum(grade)from a.sc group by sno;
实验中遇到的问题和心得体会
1.总是空格和缩进问题报错
2.表格没打全,运行没有得到想要的结果
3.因为打的表格不全所以有时候查询结果为空
4.以代码为主建表得合适