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?

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

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

### Join with account you already have

Preview

Online-Classroom Classes
www.writeabc.com

1 person following this question

1 person following this tag

Question tags

cognos × 1

Asked 2 years and 3 months ago ago
Number of Views -1600
Number of Answers -2
Last updated
3 years and 2 months ago ago

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!