六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 74|回复: 0

SQL SERVER实验-

[复制链接]

升级  38.7%

580

主题

580

主题

580

主题

探花

Rank: 6Rank: 6

积分
1774
 楼主| 发表于 2013-1-27 04:35:17 | 显示全部楼层 |阅读模式
实验3  数据检索
一、实验目的
(1)理解T-SQL语言的使用。<o:p></o:p>
(2)熟练掌握数据查询语句。<o:p></o:p>
SELECT [ALL|DISTINCT] {*|<表达式>,…,<表达式>}<o:p></o:p>
FROM <表名>[, <表名>…]<o:p></o:p>
[WHERE <条件>]<o:p></o:p>
[GROUP BY <列名>[, <列名>…][HAVING <谓词>]]<o:p></o:p>
[ORDER BY <列名> [ASC|DESC] [, <列名> ASC|DESC]…]<o:p></o:p>
[COMPUTE …] <o:p></o:p>
<o:p> </o:p>
二、实验内容
1 [3.2]b  USE CAP
select aid from AGENTS where [percent]=(select max([percent] )from AGENTS
[3.5]  Select cid,aid from customers c, agents a  Where cid not in (select cid from orders x
Where x.cid = c.cid and x.aid = a.aid)  And
aid not in (select aid from orders v  Where v.aid = a.aid and v.cid = c.cid)
[3.8]a   select cid,max(dollars) as MAXSPEND from orders group by cid
[3.8]b   select avg(MAXSPEND) average,cid from  (select cid,max(dollars) as MAXSPEND from orders group by cid)as S group by cid
[3.11]b  Select avg(temp.maxspend)avgspend,temp.cid
from (select cid,max(dollars) as maxspend from orders  
Group by cid) as temp group by temp.cid
[3.11]f  select pid from products p
where not exists(select cid from customers c where city='Duluth'
and not exists (select * from orders o where o.cid=c.cid and o.pid=p.pid))
[3.11]j  update products
set price=price*1.1 where city='Duluth' or city='Dallas'
[3.11]l  select aid,[percent] from agents a where not exists(select * from customers c
where city='Duluth' and not exists
(select * from orders o where o.cid=c.cid  and o.aid=a.aid)) order by [percent]DESC<o:p></o:p>
<选做>[3.15]、[3.16]、[3.17]<o:p></o:p>
<o:p> </o:p>
2、在“学生管理数据库”中建立四张表,分别如下:<o:p></o:p>
学生表:(主键:学号)<o:p></o:p>
            学号<o:p></o:p>
            
            姓名<o:p></o:p>
            
            性别<o:p></o:p>
            
            年龄<o:p></o:p>
            
            所在院系<o:p></o:p>
            
            班级<o:p></o:p>
            
            入学日期<o:p></o:p>
            
            20009001<o:p></o:p>
            
            葛文卿<o:p></o:p>
            
            女<o:p></o:p>
            
            22<o:p></o:p>
            
            国际贸易<o:p></o:p>
            
            国贸2班<o:p></o:p>
            
            2000-8-29<o:p></o:p>
            
            20014019<o:p></o:p>
            
            郑秀丽<o:p></o:p>
            
            女<o:p></o:p>
            
            21<o:p></o:p>
            
            会计学<o:p></o:p>
            
            会计1班<o:p></o:p>
            
            2001-9-2<o:p></o:p>
            
            20023001<o:p></o:p>
            
            刘成铠<o:p></o:p>
            
            男<o:p></o:p>
            
            18<o:p></o:p>
            
            计算机<o:p></o:p>
            
            软件2班<o:p></o:p>
            
            2002-8-27<o:p></o:p>
            
            20026002<o:p></o:p>
            
            李涛<o:p></o:p>
            
            女<o:p></o:p>
            
            19<o:p></o:p>
            
            电子学<o:p></o:p>
            
            电子1班<o:p></o:p>
            
            2002-8-27<o:p></o:p>
            
            20023002<o:p></o:p>
            
            沈香娜<o:p></o:p>
            
            女<o:p></o:p>
            
            18<o:p></o:p>
            
            计算机<o:p></o:p>
            
            软件2班<o:p></o:p>
            
            2002-8-27<o:p></o:p>
            
            20026003<o:p></o:p>
            
            李涛<o:p></o:p>
            
            男<o:p></o:p>
            
            19<o:p></o:p>
            
            计算机<o:p></o:p>
            
            软件1班<o:p></o:p>
            
            2002-8-27<o:p></o:p>
            
            20023003<o:p></o:p>
            
            肖一竹<o:p></o:p>
            
            女<o:p></o:p>
            
            19<o:p></o:p>
            
            计算机<o:p></o:p>
            
            软件2班<o:p></o:p>
            
            2002-8-27<o:p></o:p>
            
<o:p> </o:p>
课程表:(主键:课程号)<o:p></o:p>
            课程号<o:p></o:p>
            
            课程名<o:p></o:p>
            
            先修课<o:p></o:p>
            
            学分<o:p></o:p>
            
            C801<o:p></o:p>
            
            高等数学<o:p></o:p>
            
            <o:p> </o:p>
            
            4<o:p></o:p>
            
            C802<o:p></o:p>
            
            C++语言<o:p></o:p>
            
            C807<o:p></o:p>
            
            3<o:p></o:p>
            
            C803<o:p></o:p>
            
[/tr]
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表