数据库——简单单表查询
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