create table Student
(
Sno varchar(10) not null primary key,
Sname varchar(10) not null,
Ssex varchar(1) not null,
Sbirthday datetime not null,
Sage int not null,
Sdept varchar(20)
)
go
create table Coures
(
Cno int not null primary key,
Cname varchar(20) not null,
Cpno varchar(20) not null,
Ccredit int
)
go
create table SC
(
Sno int not null primary key,
Cno int not null,
Grade int
)
go
--1.
select Sno,Sname from Student
--2.
select Sname,Sno,Sdept from Student
--3.
select * from Student
--4.
select Sname,Sbirthday from Student
--5.
select Sname,Sbirthday,Sdept from Student where Sdept>='a' and Sdept<='z'
--6.
select Sname as 姓名,Sbirthday as 出生日期,Sdept as 系课 from Student
--7.
select distinct Sno from SC where Cno is not null
--8.
select Sname from Student where Sdept='计算机'
--9.
select Sname,Sage from Student where Sage<20 --方法1
select Sname,Sage from Student where not Sage>=20 --方法2
--10.
select distinct Sno from SC where Grade>=60
--11.
select Sname,Sdept,Sage from Student where Sage>=20 and Sage<=30
--12.
select Sname,Sdept,Sage from Student where Sage<20 or Sage>30
--13.
select Sname,Ssex from Student where Sno in('信息','数学','计算机')
--14.
select Sname,Ssex from Student where Sno not in('信息','数学','计算机')
--15.
select * from Student where Sno like '95001%' --方法1
select * from Student where Sno like '[9][5][0][0][1]%' --方法2
--16.
select Sname,Sno,Ssex from Student where Sname like '刘'
--17.
select Sname from Student where Sname like '欧阳_'
--18.
select Sname,Sno from Student where Sname like '_阳_'
--19.
select Sname from Student where Sname not like '刘%'
--20.
select Cno,Ccredit from Coures where Cname like 'C'
--21.
select Cno,Ccredit from Coures where Cname like 'H%T__'
--22.
select Sno,Cno from SC where Grade is null and Cno is not null
--23.
select Sno,Cno from SC where Grade is null
--24.
select Sname from Student where Sdept='计算机' and Sage<20
--25.
select Sname,Ssex from Student where Sdept='计算机' or Sdept='数学' or Sdept='信息'
--26.
select Sno,Grade from SC where Cno=3 order by Grade Desc
--27.题目好像有问题,在创建的三个表中没有找到系号
--28.
select count(*) from Student
--29.
select count(Cno) from SC where Sno is not null
--30.
select avg(Grade) as 平均成绩 from SC where Cno=1