sql 日记
--4.選擇雇用時(shí)間在1998-02-01到1998-05-01之間的員工姓名,job_id和雇用時(shí)間
select last_name,job_id,hire_date
from employees
where to_char(hire_date,'yyyy-mm-dd') between '1998-02-01' and '1998-05-01'
--5.選擇在20或50號(hào)部門(mén)工作的員工姓名和部門(mén)號(hào)
select last_name,department_id
from employees
--where department_id between 20 and 50
where department_id >=20 and department_id <=50
--6.選擇在1994年雇用的員工的姓名和雇用時(shí)間
select last_name,hire_date
from employees
--where to_char(hire_date,'yyyy')='1994'
where hire_date like '%94'
--7.選擇公司中沒(méi)有管理者的員工姓名及job_id
select last_name,job_id
from employees
where manager_id is null
--8.選擇公司中有獎(jiǎng)金的員工姓名,工資和獎(jiǎng)金級(jí)別
select last_name,salary,commission_pct
from employees
where commission_pct is not null
--9.選擇員工姓名的第三個(gè)字母是a的員工姓名
select last_name
from employees
where last_name = '__a%'
--10.選擇姓名中有字母a和e的員工姓名
select last_name
from employees
where last_name like '%a%e%' or last_name like '%e%a%'
?
1.顯示系統(tǒng)時(shí)間(注:日期+時(shí)間)
select to_char(sysdate,'yyyy-mm-dd hh:mi:ss')
from dual
--2.查詢(xún)員工號(hào),姓名,工資,以及工資提高百分之20%后的結(jié)果(new salary)
select department_id,last_name,salary,salary*(1+0.2) "new salary"
from employee01
--將員工的姓名按首字母排序,并寫(xiě)出姓名的長(zhǎng)度(length)
select last_name,length(last_name)
from employee01
order by last_name asc
--4.查詢(xún)各員工的姓名,并顯示出各員工在公司工作的月份數(shù)(worked_month)。
select last_name,hire_date,round(months_between(sysdate,hire_date),1) worked_month
from employees
--5.查詢(xún)員工的姓名,以及在公司工作的月份數(shù)(worked_month),并按月份數(shù)降序排列
select last_name,hire_date,round(months_between(sysdate,hire_date),1) worked_month
from employees
order by worked_month desc
--6.做一個(gè)查詢(xún),產(chǎn)生下面的結(jié)果
--<last_name> earns <salary> monthly but wants <salary*3>
Dream Salary
-------------------------------------------------------------------
King earns $24240 monthly but wants $72720
select last_name || ' earns ' || to_char(salary,'$999999') || ' monthly but wants ' || to_char(salary*3,'$999999') "Dream Salary"
from employees
select last_name "Last_name",job_id "Job_id",decode(
job_id,'AD_PRES','A',
'ST_MAN','B',
'IT_PROG','C',
'SA_REP','D',
'ST_CLERK','E') "Grade"
from employees
轉(zhuǎn)載于:https://www.cnblogs.com/longc/p/5962028.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
- 上一篇: [算法Tutorial]Adversar
- 下一篇: lightoj1060_组合数学