1.select count(*) from employees where last_name like _a%;key:02.select count(*)from employeeswhere to_char(hire_date,yyyy)=1998;select count(*)from employeeswhere hire_date like %98;key:23select to_char(hire_date,yyyy) from employees;3.se
1.select count(*) from employees where last_name like '_a%';key:02.select count(*)from employeeswhere to_char(hire_date,'yyyy')=1998;select count(*)from employeeswhere hire_date like '%98';key:23select to_char(hire_date,'yyyy') from employees;3.select job_title, max_salary-min_salary as sal_dieffrom jobsorder by max_salary-min_salary desc;select job_title,(max_salary-min_salary) as sal_dieffrom jobsorder by 2 desc;19行记录4.select count(*)from employeeswhere (salary>12000 or salary12000;--当它判断1000为假时就不判断后面的大于12000了.select job_id from employees;select * from employeeswhere job_id in('st_man','sh_clerk');--工作岗位名称要加单引号5.select count(*)from employeeswhere to_char(hire_date,'yyyy')=1999and to_char(hire_date,'mm')=02;key:3select count(*)from employeeswhere to_char(hire_date,'yyyy-mm')='1999-02';6.select last_name,salary,decode(trunc(salary/1500),0,'a', 1,'b', 2,'c', 'd' ) gradefrom employeeswhere last_name like'%s';7.select d.department_id,d.department_name,l.cityfrom departments d,locations lwhere d.department_id in(10,40,90)and d.location_id=l.location_id;8.select l.city,c.country_name,r.region_namefrom locations l,regions r,countries cwhere l.location_id=1000 and l.country_id=c.country_idand c.region_id=r.region_id;9.select m.last_name man_name,nvl(e.last_name,'no employees') emp_namefrom employees m,employees ewhere m.department_id=100and m.employee_id=e.manager_id(+);10行记录select m.last_name man_name,nvl(e.last_name,'no employees') emp_namefrom employees m,employees ewhere m.department_id=100and m.employee_id=e.manager_id(+);10select department_id,count(*) numfrom employeeswhere salary>8000group by department_id;9行记录11select department_id,count(*) numfrom employeeswhere salary>5000group by department_idhaving count(*)>3;3行记录12select last_name,salaryfrom employeeswhere salary>(select salary from employees where employee_id=110)and department_id=100;2行记录13select count(*) numfrom employeeswhere commission_pct12000and commission_pct is not null);24行记录