Interview Questions   Tutorials   Discussions   Programs   

Cognos - What is the difference between count and running-count functions?




1600
views
asked mar October 2, 2014 01:30 AM  

What is the difference between count and running-count functions?


           

2 Answers



 
answered By vishnoiprem   0  

For each row, this displays the quantity and a running count of the position of current row. COUNT:determine the total number of (a collection of items).

eg.
SELECT deptno,
COUNT(*) DEPT_COUNT
FROM emp
WHERE deptno IN (20, 30)
GROUP BY deptno;

DEPTNO DEPT_COUNT

20 5
30 6

running count:running count of the position of current row Eg

SELECT empno, deptno, 
COUNT(*) OVER (PARTITION BY 
deptno) DEPT_COUNT
FROM emp
WHERE deptno IN (20, 30);

 EMPNO     DEPTNO DEPT_COUNT
  7369         20          5
  7566         20          5
  7788         20          5
  7902         20          5
  7876         20          5
  7499         30          6
  7900         30          6
  7844         30          6
  7698         30          6
  7654         30          6
  7521         30          6
flag   
   add comment

 
answered By vishnoiprem   0  

For each row, this displays the quantity and a running count of the position of current row. COUNT:determine the total number of (a collection of items).

eg.
SELECT deptno,
COUNT(*) DEPT_COUNT
FROM emp
WHERE deptno IN (20, 30)
GROUP BY deptno;

DEPTNO DEPT_COUNT

20 5
30 6

running count:running count of the position of current row Eg

SELECT empno, deptno, 
COUNT(*) OVER (PARTITION BY 
deptno) DEPT_COUNT
FROM emp
WHERE deptno IN (20, 30);

 EMPNO     DEPTNO DEPT_COUNT
  7369         20          5
  7566         20          5
  7788         20          5
  7902         20          5
  7876         20          5
  7499         30          6
  7900         30          6
  7844         30          6
  7698         30          6
  7654         30          6
  7521         30          6
flag   
   add comment

Your answer

Join with account you already have

FF

Preview


Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!

Alert