oracle 内外连接


select rbm1.id,rbm1.rbm_email,to_char(rbm1.out_of_office,'MM/DD/YYYY') OFFICE ,rbm2.rbm_email BACKUPEMAIL
from icod_rbms rbm1 LEFT  JOIN icod_rbms rbm2 on( rbm1.backup = rbm2.id )
where rbm1.region='AAA'
(on用来关联表之间的关系)


select rbm1.id,rbm1.rbm_email,to_char(rbm1.out_of_office,'MM/DD/YYYY') OFFICE ,rbm2.rbm_email BACKUPEMAIL
from icod_rbms rbm1 , icod_rbms rbm2 where rbm1.backup = rbm2.id (+)
and rbm1.region='AAA'


  --
  select to_char(sysdate, 'yyyy/mm/dd') from dual;
  select sysdate from dual

  --获取30天前日期
  select trunc(sysdate - 30) from dual;

你可能感兴趣的:(oracle)