1、查询 pubs 数据库的 titles 表中版税 (royalty) 为 10 的每类 (类型字段为 type) 图书的数量和平均价格2、查询 pubs 数据库的 titles 表中每类图书中图书的数量超过3本的图书的总价格3、查询 northwind 数据库中,查询雇员 (eployees 表) 和顾客 (customers 表) 都来自哪些城市 (City表) 并将结果按城市的字母升序排序
调试欢乐多
goselect type,count(*) as cnt,avg(price) as avg_price
from titles
where royalty=10
group by type;select type,sum(price) as total_price
from titles
group by type
having count(*) > 3;gouse northwind
go
select employeename as name,city
from employees
union all
select customername ,city
from customers
order by name
use pubs
go
select
图书名,sum(图书名),avg(图书名)
from
titles
where
royalty=10
type,sum(price) as total_price
from
titles
group by
type
having
count(*) > 3
select
employeename as name,city
from
employees
union all
select
customername ,city
from
customers
order by name
select type, ave(价格) as 平均价, count(1) as 数量
from pubs.title
where royalty = 10
group by typeselect sum(价格) as 总价, type
from pubs.title
group by type
having count(1)>3select *
from City
where id in (select city_id from eployees ) or id in (select city_id from customers )
from pubs.title
where royalty = 10
group by typeselect sum(价格) as 总价, type
from pubs.title
group by type
having count(1)>3select *
from City
where id in (select city_id from eployees ) or id in (select city_id from customers )
order by name
修改一下排序