关于SQL2000

    我是在一家培训中心学习JAVA的,由于做JAVA开发必需要和数据库打交道,所以培训课程安排中有这方面的安排.我们先学的是SQL2000,后期学了ORACLE.
    关于SQL的一些资料我放在了我的资源里面(博客里好像不给上传东西),有需要的就麻烦自己去找啦,呵可.
    这里只将我学习期间做的一些题发上来让大家看一下,有什么错误还请大家多多指教.
    全都是SQL自带的数据库,先是PUBS数据库的.
 1.在pubs库中的publishers表中查找所有出版商业书籍的出版商的名称,用EXIST关键字完成
2.在pubs库中的publishers表中查找所有出版商业书籍的出版商的名称,用IN关键字完成
3.查找至少曾参与编写一本热门计算机(popular_comp类型)书的作者姓名
4.查找销售数量低于该书同类型平均销售数量(销售数量ytd_sales)的书的信息。
5.找到与 Livia Karsen 住在同一城市的作者

1.(where子句中要有两个条件)
select pub_name from publishers as p
where  exists
(select pub_id from titles as t
 where  p.pub_id=t.pub_id
  and type='business')
2.
select pub_name,pub_id from publishers
where pub_id in
(select pub_id from titles where type='business')


3.
select au_lname,au_fname from authors
where au_id in
(
 select au_id  from titleauthor where au_id in
 (
  select au_id from titles where titleauthor.title_id=titles.title_id
 and type='popular_comp'
 )
)


(另一种方法)
select au_id,au_lname,au_fname from authors
where au_id in
 (select au_id from titleauthor
 where title_id in
  (select title_id from titles
  where type = 'popular_comp'))

4.  ★★★★★
select *
from titles as a
where ytd_sales <
(
  select avg(ytd_sales)
  from titles as b
  where a.type = b.type
)


5.
select *from authors
where  city in    --in可以换成'='
(select city from authors
where au_fname='livia' and au_lname='karsen' )

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值