文档详情

数据库应用考试复习_3解析.ppt

发布:2017-01-11约5.78千字共19页下载文档
文本预览下载声明
Public Sub p1() Dim s As Integer, t As Integer, i As Integer s = 24 t = 18 i = 24 Do While i = 1 If s / i = Int(s / i) And t / i = Int(t / i) Then Debug.Print i= + Str(i) Exit Do End If i = i - 1 Loop End Sub i=6 Public Sub p2() Dim a1 As Integer, s As Integer, i As Integer a1 = 1 s = 0 For i = 1 To 5 s = s + a1 a1 = a1 * 2 Next Debug.Print a1= + Str(a1) Debug.Print s= + Str(s) Debug.Print i= + Str(i) End Sub a1= 32 s= 31 i= 6 Public Sub p3() Dim s As Integer, i As Integer, n As Integer s = 0 n = 0 For i = 1 To 21 If i / 4 = Int(i / 4) Then s = s + i n = n + 1 End If Next Debug.Print n= + Str(n) Debug.Print s= + Str(s) Debug.Print i= + Str(i) End Sub n= 5 s= 60 i= 22 1、查找与“杨小件”同一个工作单位的读者编号、姓名、性别和工作单位 Select 读者编号,姓名,工作单位 Feom 读者 Where 工作单位 in (select 工作单位 from 读者 where 姓名=“杨小件”) 2、查找读者“马小虎”所借图书的分类名称,消除重复 Select distinct 分类名称 From 读者 a,借阅 b,图书 c,图书分类 d Where a.读者编号=b.读者编号 and b.图书编号=c.图书编号 and c.分类号=d. 分类号 and 姓名=“马小虎” 3、查找名称中包含“数据库”字样的图书信息 Select * From 图书 Where 图书名称 like “*数据库*” 4、查找入库时间与出版时间在同一年份的图书编号、图书名称、分类名称 Select a.图书编号,图书名称,分类名称 From 图书 a,图书分类 b Where a.分类号=b.分类号 and year(出版时间)=year(入库时间) 5、查找每种分类图书的最高价和平均价,按平均价的降序输出 Select 分类号, max(单价) as最高价,avg(单价) as 平均价 From 图书 Group by 分类号 Order by avg(单价) desc 6、查找借阅过图书数量超过6本的读者编号、姓名、图书编号、图书名称, 按读者编号排序输出 Select a.读者编号,姓名,b.图书编号,图书名称 From 读者 a,借阅 b,图书 c Where a.读者编号= b.读者编号 and b.图书编号= c.图书编号 and a.读者编号 in (select 读者编号 from 借阅 group by 读者编号 having count(*)=6) Order by a.读者编号 单项选择题 1、数据库(DB)、数据库系统(DBS)和数据库管理系统(DBMS)之间的关系是( )。 A、DBMS包括DB和DBS? ?? ?? B、DBS包括DB和DBMS C、DB包括DBS和DBMS? ?? ?? ?? ???D、三者之间是平等的关系 2、表达式(a = a+1)是( )。 A、算术表达式 ?? B、关系表达式
显示全部
相似文档