Results 1 to 2 of 2

Thread: Display Records with subtotal

  1. #1
    Join Date
    Mar 2007
    Posts
    6

    Display Records with subtotal

    Need to display all records with the subtotals at the bottom grouped by say name column. I need to get the result in a cursor so i can pass the value to the open system.

    I am able to get subtotal separately using sum and group by functions. But in the cursor the result set should be in the following format

    Eg:

    H 20
    H 10
    30
    K 40
    K 20
    K 10
    70
    S 10
    10
    110

  2. #2
    Join Date
    Jul 2007
    Posts
    1

    using Rollup and CUbe commands

    Rollup command is used to finding the sub totals


    select deptno, job, count(*), sum(sal)from emp group by rollup(deptno,job)


    select deptno, job,count(*), sum(sal) from emp
    group by cube(deptno, job)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •