我们背着压力不停地追赶不断地努力,到最后才发觉,我们真正想要的就是幸福........................................ 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')51Testing软件测试网m4?+v&s| \:K cF

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

:_w@N.uq9Pj3H0

from employees;  ( 17 6 1987)51Testing软件测试网0_#rf|]2Z vb7Wq

function: to_char(number ,’format_model’)51Testing软件测试网_p8Y%_I!eOw;[

LS: select to_char(salary,'$99,999.00') salary from employees

A^ g(};j9^ Xk0

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

Zm'U7e%z.`/v0

If we change '$99,999.00' into 'L99,999.00', then enquerying result is (RMB6,000.00)

!m:Ot2@U0

 2, function to_number () and to_date()51Testing软件测试网0M(E3c Ec'B

 3,nesting functiom

7wYSN.[T0dR0

nvl(expr1, expr2)  if expr1 is null. Then change expr1 into expr251Testing软件测试网/]2wY7\)Z@

nvl2(expr1,expr2,expr3) if expr1 isn’t null, change expr2 into expr1, else change expr3 into expr151Testing软件测试网 rv${N9Rxh(u._

 4, function nullif()

8G A]"x!g5Tx p6kK0

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)

$Ar Bl'[Q`6c4Y o4J0

 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………..

wrL Q7H9OT2?T%i5o$m0

 6,case expression

a%T:vD/K\K c0

select last_name,job_id,salary,51Testing软件测试网|+L F$X;K KQ

case job_ID WHEN 'IT_PROG' THEN 1.10*salary51Testing软件测试网ld'v?Irw'O

            WHEN 'ST_CLERK' THEN 1.15*salary

J:tW E%|Tlb0

            WHEN 'SA_REP' THEN 1.20*salary

_{J C(@%J0

else salary  

0T)s!? i:T0

end "REVISED_SALARY"

O(`:K8p$i:QF!~ I0

FROM employees;

)@2m7cM6Ms0

(

9_CR6l%LR s ce0

King 51Testing软件测试网M X TZ0Ck

AD_PRES 51Testing软件测试网d$HZ%ZTf

24000

W CR ur#z`aSlZ.Fp0

24000 51Testing软件测试网 \(X}6dH~ En

Ernst

R:F4l,R:a"Mi0

IT_PROG 51Testing软件测试网l~$JwY3krj

6000 51Testing软件测试网4P!Sg%Nc#V;N$Mkp#^

6600 51Testing软件测试网0e"R6Dr Z1vC

)

?Sq7zt5U"s0

7,join type: use join to query data from more than one table.51Testing软件测试网!z@)@ U5^Z.a/]GR

 Equijoin : where e.department_id=d.department_id

;W0L@ R[0

 Non-equijoins : where e.salary  between j.lowest_sal and j.highest_sal;51Testing软件测试网;W6vnoF x%t.~

 Outer joins ; where e.department_id(+)=d.department_id  

?.A"o3{&oJDETo0

 Self joins :we should name alias name for the table.

l+[ ]'q4n4`1L0

 Select worker.last_name ||’work for’ || manager.last_name from employees worker ,employees manager  where ………..

\"e'r K+q0

8,Types of group function51Testing软件测试网-C[Y;bk _!qgi T

 Avg() :select department_id,avg(salary) from employees group by department_id51Testing软件测试网V E7EFv9r"r/Y

select department_id,max(salary) from employees group by department_id;

,|Y9O5~*uB&GdJd0

having(max(salary)>10000);  (having() can only affect group)51Testing软件测试网-M BQ)Fmvi3d?

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

{fX,RRh5z lpR0

Max()

uNT?9[;Ky0?M0|5y U1B0

Min()

iCa(S'};Cw^0

Sum()51Testing软件测试网R1]Gho2o)@|0rH Y(I

 

.F+H4dvyNw0

TAG:

 

评分:0

我来说两句

日历

« 2024-05-23  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

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

RSS订阅

Open Toolbar