10-210 在顾客表中查询公司城市在“济南”的顾客数目
select count(城市) as 济南顾客数
from 顾客
where 城市='济南'
10-212 在员工表中查询姓陈的男职工的全部信息
select * from 员工
where 性别='男' and 姓名 like'陈%';
10-213 在员工表中查询陈诚瑞和钟鸣的全部信息
select * from 员工
where 姓名='陈诚瑞' or 姓名='钟鸣';
10-216 在顾客表中查询青岛的顾客编号,公司名称和电话,结果按顾客编号升序排列
select 顾客编号,公司名称,电话 from 顾客
where 城市='青岛'
order by 顾客编号 asc;
10-217 在顾客表中查询各个城市的顾客数目
select 城市,count(*) as 顾客数 from 顾客
group by 城市;
10-218 在订单表中查询运费的平均值
select avg(运费) as 平均运费 from 订单;
10-219 通过订单表和顾客表,查询订单编号,顾客编号,公司 名称和订单日期
select 订单.订单编号,订单.顾客编号,顾客.公司名称,订单.订单日期
from 订单,顾客
where 订单.顾客编号=顾客.顾客编号
;
10-220 在顾客表中查询出现了那些城市,要求不显示重复值
select distinct 城市 from 顾客;
10-223 在订单表中查询011号员工和121号员工承办的订单信息
select * from 订单
where 员工编号='011' or 员工编号='121';
10-233 ignore-order-sample,
检索出Student
表中所有符合id > 50
的记录。
select *
from Student
where id < 50
order by id asc;
10-240 查询未登记成绩的学生
select sno from sc
where grade is null;
10-243 A4-5统计职工表中职务的数量
统计职工表(employees)
中职务(Title)
的个数,并重命名为countTitle
select count(distinct Title) as countTitle
from employees;
10-244 6-1 查询PC的平均速度
select avg(speed) as avg_speed
from pc;
10-245 A4-6查找订单表中特定顾客编号的相关信息
查询订单表(orders)
中以字母V
打头的顾客编号(CustomerID)
产生的订单信息,结果显示为顾客编号(CustomerID)
和总运费(sumFreight)
select CustomerID,sum(Freight) as sumFreight
from orders
where CustomerID like 'V%'
group by CustomerID;
10-246 6-5 查询各种不同速度的PC的平均价格
select speed,avg(price) as avg_price
from pc
group by speed;
10-254 查询'CS'系有哪些学生
select * from student where sdept='CS';