数据库基本sql语句一

来源:互联网 发布:北影的明星 知乎 编辑:程序博客网 时间:2024/05/17 22:43
1.选择在部门 30 中员工的所有信息


SELECT * FROM  EMP  WHERE DEPETNO='30


2.列出职位为(MANAGER)的员工的编号,姓名


select t.empno,t.ename  from emp t  where t.job='MANAGER'




3.找出奖金高于工资的员工


SELECT * FROM EMP t WHERE t.comm>t.sal




4.找出每个员工奖金和工资的总和


select t.ename ,(comm+sal) as salary from emp  t




5.找出部门 10 中的经理(MANAGER)和部门 20 中的普通员工(CLERK)


select * from emp t where t.deptno=10  and t.job='MANAGER' OR  t.deptno=20 and t.job='CLERK'




6. 找出部门 10 中既不是经理也不是普通员工,而且工资大于等于    2000 的员工


select * from emp t where t.deptno=10 and t.job not in('MANAGER','CLERK') AND t.sal>=2000




7. 找出有奖金的员工的不同工作


select distinct job from emp where comm is not null and comm>0


8.找出没有奖金或者奖金低于 500 的员工


select * from emp t where t.comm<500 or t.comm is null


9.显示雇员姓名,根据其服务年限,将最老的雇员排在最前面


select  t.first_name  from employees t order by  t.hire_date
0 0
原创粉丝点击