“21天好习惯”第一期-11

数据库——简单单表查询

1. (其它)针对bookshop数据库,查找所有经理的姓名、职称、薪水。(注:“经理”是一种职称)

select emp_name,title,salary
from employee
where  title='经理'

2. (其它)针对bookshop数据库,在销售主表sales中查找销售金额大于等于100元的订单。

select *
from sales
where tot_amt>=100

3. (其它)针对bookshop数据库,在员工表employee中查找薪水在40000至80000元之间的员工。

select *
from employee
where salary between 40000 and 80000

4. (其它)针对bookshop数据库,在员工表employee中查找住址为上海市、北京市、天津市这三个城市的员工。

select * 
from  employee
where addr in('上海市','北京市','天津市')

5. (其它)针对bookshop数据库,在客户表customer中查找收货人不是帅宜阳、钟博文、张旭达这三个人的客户的信息。

select *
from customer
where receiver  not in ('帅宜阳','钟博文','张旭达')

6. (其它)针对bookshop数据库,在员工表employee中查找姓“王”且姓名最后一个字为“功”的员工。

select * 
from  employee
where emp_name like '王%功'

7. (其它)针对bookshop数据库,在客户表customer中查找收件人是姓“张”的客户名称、电话。

select  [cust_name],[tel_no]
from customer
where receiver like '张%'

8. (其它)针对bookshop数据库,查找出职称为“经理”或“职员”的女工的信息。

select * 
from employee
where title in('经理','职员') and sex='女'

9. (其它)针对bookshop数据库,查找员工表中所属部门。(去掉重复记录)

select distinct dept
from employee

10. (其它)针对bookshop数据库,查找薪水最高的前三条员工记录。(提示:这里要用order by 降序排序)

select top 3 *
from employee
order by salary desc

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值