GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Tech FAQs  >  PL/SQL

 Print  |  
Question:  Analytical functions

Answer: What are analytical functions and how are they used?


July 07, 2008 02:31:08 #1
 singh.neerajin Database Expert  Member Since: May 2008    Total Comments: 4 

RE: Analytical functions
 
Analytic functions compute an aggregate value based on a group of rows. They differ from aggregate functions in that they return multiple rows for each group. The group of rows is called a window and is defined by the analytic_clause.

for example:

SQL> select deptno,
  2  ename,
  3  sal,
  4  sum(sal) over (partition by deptno
  5  order by sal,ename) CumDeptTot,
  6  sum(sal) over (partition by deptno) SalByDept,
  7  sum(sal) over (order by deptno, sal) CumTot,
  8  sum(sal) over () TotSal
  9  from emp
10  order by deptno, sal;


over by clause, order by clause,partition ny clause comes under anyalytical clause.....
check below.
select ... analytic-function (...) over (partition by ...) .. select ... analytic-function (...) over (order by ...) .. select ... analytic-function (...) over (partition by ... order by ...) .. 
     

 

Back To Question