前端之家收集整理的这篇文章主要介绍了
万事俱备之ORACLE_SQL 练手 part3,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
select * from employees;
select * from DEPARTMENTS;
select * from locations;
SELECT TO_CHAR(SALARY,'U99,999.99','NLS_DUAL_CURRENCY=RMB') FROM EMPLOYEES WHERE ROWNUM < 5;
SELECT TO_CHAR(SALARY,'$99,999.99') FROM EMPLOYEES WHERE ROWNUM < 5;
SELECT TO_CHAR(SALARY,'99,999.$99') FROM EMPLOYEES WHERE ROWNUM < 5;
SELECT TO_CHAR(SALARY,'C99,999.99') FROM EMPLOYEES WHERE ROWNUM < 5;
SELECT TO_CHAR(SALARY,'L99,999.99') FROM EMPLOYEES WHERE ROWNUM < 5;
SELECT TO_CHAR(SALARY,'L099,999.99') FROM EMPLOYEES WHERE ROWNUM < 5;
alter session set NLS_ISO_CURRENCY='China';
alter session set NLS_CURRENCY='RMB';
alter session set NLS_CURRENCY='¥';
select * from v$nls_parameters;
select * from nls_database_parameters;
ALTER DATABASE NATIONAL CHARACTER SET INTERNAL_USE UTF8;
alter system set nls_language='SIMPLIFIED CHINESE' scope=spfile;
select first_name,sal,round(sal*1.08) Acsal_now from (select first_name,salary sal from employees where rownum < 6);
select first_name,salary sal,round(salary*1.08) sal_now from employees where rownum < 6;
select upper(first_name) from employees where manager_id is null;
select first_name||' '||last_name ename from employees where employee_id= (select manager_id from employees where first_name= 'David' and last_name='Austin' );
select first_name||' '||last_name ename from employees where manager_id= (select employee_id from employees where first_name= 'Alexander' and last_name='Hunold' );
select a.first_name||' '||a.last_name ename,a.salary,b.first_name||' '||b.last_name mname,b.salary from employees a,employees b where a.manager_id=b.employee_id and a.salary > b.salary;
select a.first_name||' '||a.last_name ename,b.salary from employees a inner join employees b on a.manager_id=b.employee_id and a.salary > b.salary;
select first_name||' '||last_name ename,department_id from employees where department_id = (select department_id from employees where last_name='Chen');
select first_name||' '||last_name ename,job_id from employees where job_id = (select job_id from employees where last_name='De Haan');
select first_name||' '||last_name ename,department_id from employees where department_id != (select department_id from employees where last_name='Hall');
select first_name||' '||last_name ename,job_id from employees where job_id != (select job_id from employees where last_name='Smith' and FIRST_NAME='William');
select first_name|| ' ' ||last_name ename,commission_pct,empp.department_id,department_name,city from employees empp left join (select d.department_name,l.city,department_id from locations l right join departments d on l.location_id= d.location_id) locdept on locdept.department_id =empp.department_id where commission_pct is not null;
select empp.job_id from employees empp right join departments d on empp.department_id=d.department_id where d.department_name ='Executive';
select max(salary)-min(salary) from employees;
select count(*) num from employees where commission_pct>0;
select round(max(salary)),round(min(salary)),round(avg(salary)),round(sum(salary) ) from employees;
select count(distinct manager_id) cmn from employees ;
select first_name|| ' ' ||last_name ename,salary,hire_date from employees empp left join (select department_id,max(hire_date),salary maxsal from employees group by department_id) maxsal on empp.department_id = maxsal.department_id where empp.hire_date>=maxsal.hire_date and empp.salary>=maxsal.;
select distinct e1.first_name||' '||e1.last_name,e1.salary,e1.hire_date from employees e1 join employees e2 on e1.department_id=e2.department_id where e1.hire_date> e2.hire_date and e1.salary>e2.salary;
原文链接:https://www.f2er.com/oracle/206471.html