这个是我自己做的, 请高手帮我修改修改哪些错了!万分感谢!---------------------------------1请查询发行书籍最多的发行商名称和它发行书籍的数量---------------------
select max(ytd_sales) AS 最大销售额,pub_name
from titles inner join publishers
on titles.pub_id=publishers.pub_id
group by pub_name
----------------------------------2请查询每个地区每个城市居住的作者人数,以及每个地区居住的作者人数。(提示:使用rollup)------------------------
-----------------------------------3查询销售了所有书籍的书店名称--------------------------------------------------------------------------------
select distinct  stor_name
from titles,sales,stores
where stores.stor_id=sales.stor_id and
sales. title_id=titles.title_id
------------------------------------4查询销售了所有商业类书籍的书店名称-----------------------------------------------------------
select distinct  stor_name
from titles,sales,stores
where titles.type='business' and stores.stor_id=sales.stor_id and
sales. title_id=titles.title_id
-----------------------------------5-查询得到每本书籍以及该书籍的发行商名称、销售该书籍的书店个数--------------------------------------
select count(*) AS number ,title,pub_name
from stores,publishers,titles,sales
where  stores.stor_id=sales.stor_id and
sales. title_id=titles.title_id and titles.pub_id=publishers.pub_id
group by title,pub_name
------------------------------------6查询单价最高的书籍一共被订购的数量-------------------------
select qty,title
from titles,sales
where  price =(select max (price)
from titles) and sales.title_id=titles.title_id 
group by title,qty-------------------------------------7查询定单时间在1994年2月到6月之间的销售记录----------------select  *
from sales 
where ord_date  between '1994-2-01' and '1994-6-01'
----------------------------------------8查询1994年9月销量最好的图书名称--------------------------
select  title
from titles,sales
where qty=( select max (qty)
from sales)and ord_date between '1994-9-1' and '1994-9-31'
 and sales.title_id=titles.title_id 
----------------------------------------9查询编号为‘7066’和‘7067’书店同时销售了的书籍名称
select  distinct title
from titles,stores
where  stor_id in ('7066','7067')
------------------------------------10查询价格在书籍平均价格以下的书籍名称--------------------
select  title
from titles
where price <(select  avg (price)
from titles)
----------11查询销售了发行商名称为“New Moon Books”的发行商所发行书籍的书店名称-----
select distinct  stor_name
from stores,publishers,titles,sales
where pub_name='New Moon Books'
 and publishers.pub_id=titles.pub_id 
and titles.title_id=sales.title_id 
and  sales.stor_id=stores.stor_id
-------------------------------------------12查询销售额最高的书店名称------------------------------------------
select  stor_name
from stores ,titles,sales
where ytd_sales=(select max(ytd_sales)
from titles) and  titles.title_id=sales.title_id 
and  sales.stor_id=stores.stor_id
--------------------------------------------13查询每本书籍的名称和该书发行商的名称--------------
select title,pub_name
from titles AS a inner join publishers AS b
on a.pub_id=b.pub_id
-------------------------------------------14查询每个国家发行商的数量-------------------
select country ,count (*) AS 发行商数量
from publishers
group by country
------------------------------------------15请查询书籍表中每本书籍被订购的数量-----------
select qty,title
from sales, titles 
where
titles.title_id=sales.title_id 
group by title,qty
----------------16由于物价上涨,请将“mod_cook”类的每本书籍的售价提高一成-------------
update titles
set price=price+price*0.1
where type='mod_cook'
select * from titles
----------------------17请删除卖不出去的书籍(删除销售表中不存在的书籍信息)????--------
delete titles
from titles,sales
where titles.title_id!=sales.title_id
-----------18请查询单价最高和单价最低的书籍信息-----------------------------
select *
from titles 
where price=(select max(price)
from titles) 
select *
from titles 
where 
price=(select min(price)
from titles)