top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

how to write a query to get the matrix report in Oracle SQL?

0 votes
769 views
how to write a query to get the matrix report in Oracle SQL?
posted Sep 22, 2014 by Vidhya Sagar

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

Method 1: Using a subquery

    SELECT *
    FROM   emp
    WHERE  (ROWID,0) IN (SELECT ROWID, MOD(ROWNUM,4)
                         FROM   emp);

Method 2: Use dynamic views;

    SELECT *
    FROM   ( SELECT rownum rn, empno, ename
             FROM emp
           ) temp
    WHERE  MOD(temp.ROWNUM,4) = 0;

Method 3: Using GROUP BY and HAVING

SELECT rownum, f1
FROM t1
GROUP BY rownum, f1 HAVING MOD(rownum,n) = 0 OR rownum = 2-n
answer Sep 23, 2014 by Arun Gowda
...