标题:SQL经典练习
只看楼主
Santos
Rank: 1
来 自:上海
等 级:新手上路
帖 子:4
专家分:0
注 册:2009-8-16
得分:0 
做了一下 以前学的大多数没有忘记
2009-08-18 20:39
holydie
Rank: 2
等 级:论坛游民
帖 子:15
专家分:58
注 册:2009-8-26
得分:0 
拿来练手正好,我新手,谢谢楼主啦
2009-08-26 09:36
lls407063674
Rank: 1
等 级:新手上路
帖 子:23
专家分:2
注 册:2009-9-4
得分:0 
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
2009-09-06 12:18
huxiaoxi0223
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2009-9-15
得分:0 
很全的题目啊,,
2009-09-15 16:50
olderdream
Rank: 1
等 级:新手上路
帖 子:110
专家分:0
注 册:2009-3-17
得分:0 
多谢分享,学习中!
用空拿来练习练习,刚入门,正需要这些东东!谢谢!
2009-09-21 08:07
olderdream
Rank: 1
等 级:新手上路
帖 子:110
专家分:0
注 册:2009-3-17
得分:0 
那位老大弄点实例数据呗,好像这样更容易理解!
2009-09-21 08:12
itcenter1
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-5-8
得分:0 
初学者,谢谢分享
2010-05-11 08:06
tengbogulang
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2011-9-4
得分:0 
看来还要努力学习啊
2011-09-04 22:01



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-49053-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.174573 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved