Results 1 to 3 of 3

Thread: Query Doubt

  1. #1
    Contributing Member
    Join Date
    Mar 2008
    Answers
    66

    Query Doubt

    Upto this part it is working correctly

    SELECT replace(to_char(decode(lead(deptno,1,NULL) over(order by deptno) ,deptno,deptno,100)),'100','Total')deptno,
    Job, Sum(sal)
    FROM emp
    GROUP BY rollup (deptno,job)

    How to display Grand Total Message for the last row
    SELECT reaplce(replace(to_char(decode(lead(deptno,1,NULL) over(order by deptno) ,deptno,deptno,100)),'100','Total'),NULL,'GrandTotal')deptno,
    Job, Sum(sal)
    FROM emp
    GROUP BY rollup (deptno,job)

    In the above query I have given null which is not correct. can anyone suggest alternate solution for that?


  2. #2

    Re: Query Doubt

    U better ask the same question at oracle network group.....


  3. #3
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: Query Doubt

    use this query

    select decode(deptno,'Total','Total',null,'GrandTotal',deptno) deptno,job,sal from
    (SELECT replace(to_char(decode(lead(deptno,1,NULL) over(order by deptno) ,deptno,deptno,100)),'100','Total') deptno,
    Job, Sum(sal) sal
    FROM scott.emp
    GROUP BY rollup (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
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact