我们背着压力不停地追赶不断地努力,到最后才发觉,我们真正想要的就是幸福........................................ Travelling in real lify with my dream and enthusiasm

oracle train 2

上一篇 / 下一篇  2007-10-13 11:34:20

1,  Function : to_char(hire_date,'format_model')

%@f0]+W9~?0

LS: select last_name, to_char(hire_date,'fmDD Month YYYY')AS HIREDATE

$^)@TL(m0

from employees;  ( 17 6 1987)51Testing软件测试网S qT U1Tt5[(g6KZ

function: to_char(number ,’format_model’)

7go'` e}xWm0

LS: select to_char(salary,'$99,999.00') salary from employees51Testing软件测试网}!D9ao:c6j(Y

where last_name='Ernst';   ($6,000.00)

/?R2}*K;AH)w0

If we change '$99,999.00' into 'L99,999.00', then enquerying result is (RMB6,000.00)51Testing软件测试网(T4^+H(Gu4Z8u

 2, function to_number () and to_date()51Testing软件测试网'YJ{K_/?

 3,nesting functiom51Testing软件测试网%y1i&jP"[0R

nvl(expr1, expr2)  if expr1 is null. Then change expr1 into expr251Testing软件测试网\P#x4{@9E.p |

nvl2(expr1,expr2,expr3) if expr1 isn’t null, change expr2 into expr1, else change expr3 into expr1

-hH,FAz0

 4, function nullif()

p#x;etA:l-P0

nullif(length(last_name),length(first_name)) , if length(last_name)=length(first_name), then values of nullif() is null, else …..is length(last_name)51Testing软件测试网S$m$GVe"~ Mo

 5,function coalesce(1,2,3, ) if 1 isn’t null, the values of this function is 1, else judge 2,if 2 isn’t null, then 2 is this function’s values,else………..

kB r#A+i1h0a*[cx0

 6,case expression51Testing软件测试网e5RJ"|m1T

select last_name,job_id,salary,

7q3BUYoxz-c`7o Y)m0

case job_ID WHEN 'IT_PROG' THEN 1.10*salary51Testing软件测试网*}U] r*URyp/Yr"Z+J

            WHEN 'ST_CLERK' THEN 1.15*salary

4p&[5A|I0

            WHEN 'SA_REP' THEN 1.20*salary51Testing软件测试网7clQ^$zbJ n&E9_

else salary  

r"jSr6E~E6l4W0

end "REVISED_SALARY"

]@^w1d0

FROM employees;

6q#aN4b8XN,U)~0

( 51Testing软件测试网3g!W&H-f*n

King

)G-i!ZARH$IK0

AD_PRES

p'c&Z}*vyR0

24000

+PkWQ,a0

24000

P b-_Kc#R!P&L0

Ernst 51Testing软件测试网 Pg%|8wp4jva-oA%C

IT_PROG 51Testing软件测试网k/r5z9KX-fc3k/_!V

6000 51Testing软件测试网g*s E:l$m Z1C

6600

UZAu){2O l0

)51Testing软件测试网8W}9xk?A

7,join type: use join to query data from more than one table.

(x5E/M5Z2~zX0

 Equijoin : where e.department_id=d.department_id

F[ g J7GD'p5A;s0

 Non-equijoins : where e.salary  between j.lowest_sal and j.highest_sal;51Testing软件测试网+b`T3uB3ia

 Outer joins ; where e.department_id(+)=d.department_id  51Testing软件测试网9I-\'I^8S7Y%R

 Self joins :we should name alias name for the table.51Testing软件测试网e~;D@N7j

 Select worker.last_name ||’work for’ || manager.last_name from employees worker ,employees manager  where ………..51Testing软件测试网4a)c6?c qQF5T'MJ@

8,Types of group function51Testing软件测试网V^jH)gs0_ Qk

 Avg() :select department_id,avg(salary) from employees group by department_id

-JrgL^L#Q0

select department_id,max(salary) from employees group by department_id;51Testing软件测试网 _:P \EuY

having(max(salary)>10000);  (having() can only affect group)

jZq0A:Rc2v0

Count() , count(distinct department_id)/count (department_id)/count(*)

"v a+^s H?0

Max()

2baMc"TK M0

Min()

qUXGe?`'P0

Sum()51Testing软件测试网5X!nM#^ AX

 

M'HZ%^.v H l8qr0

TAG:

 

评分:0

我来说两句

日历

« 2024-04-22  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 13869
  • 日志数: 30
  • 图片数: 1
  • 建立时间: 2007-03-17
  • 更新时间: 2008-01-04

RSS订阅

Open Toolbar