How to display sum of amount at bottom of row
How to display sum of amount at bottom of row
Dear all,
How to print the Total amount/salary at the bottom of line without using break on and compute commands.
How to print the Total amount/salary at the bottom of line without using break on and compute commands.
Dear Amirtai,
Thanks for given idea. But, in my query date column is present at this scenario how to write a query. Kindly suggest to me. For more clarification i mentioned one simple query in below.
select ename,sal,job,hiredate from emp
union
select 'Total',sum(sal),'', <font color="red">DATE Column </font id="red"> from emp
In above example, how can a write same date expressioin(above red color).
Thanks for given idea. But, in my query date column is present at this scenario how to write a query. Kindly suggest to me. For more clarification i mentioned one simple query in below.
select ename,sal,job,hiredate from emp
union
select 'Total',sum(sal),'', <font color="red">DATE Column </font id="red"> from emp
In above example, how can a write same date expressioin(above red color).
Dear Amirtai,
Thanks for prompt response. But, In my scenario <b>query takes a long time for execution</b>. Please let me know, how can reduce the execution time. And also i want to present a number data type instead of varchar type at the bottom of result row. I mentioned one example below
select ename,sal,hiredate from emp
union
select <font color="red">sum(case when sal<0 then 1 else 0 end)</font id="red">,sum(sal),sysdate from emp
In above example, the red color mentioned result is number data type but ENAME column is varchar type. Is possible to print the number data type in varchar type.
Thanks for prompt response. But, In my scenario <b>query takes a long time for execution</b>. Please let me know, how can reduce the execution time. And also i want to present a number data type instead of varchar type at the bottom of result row. I mentioned one example below
select ename,sal,hiredate from emp
union
select <font color="red">sum(case when sal<0 then 1 else 0 end)</font id="red">,sum(sal),sysdate from emp
In above example, the red color mentioned result is number data type but ENAME column is varchar type. Is possible to print the number data type in varchar type.
Hello
Please post the execution plan for your query and we'll see what could be done to optimize it.
The pre-condition for using UNION clause is, column type must match for each corresponding column in the second query or it can be NULL. You could convert the column type in your second query, for instance:
select ename,sal,hiredate
from emp
union
select to_char(count(case when sal > 0 then 1 else null end)),sum(sal),sysdate
from emp
Amir
Please post the execution plan for your query and we'll see what could be done to optimize it.
The pre-condition for using UNION clause is, column type must match for each corresponding column in the second query or it can be NULL. You could convert the column type in your second query, for instance:
select ename,sal,hiredate
from emp
union
select to_char(count(case when sal > 0 then 1 else null end)),sum(sal),sysdate
from emp
Amir
Who is online
Users browsing this forum: No registered users and 0 guests