i have one table with accounts and amounts as
colums.accounts with columns c and d. and amounts with
values 1000,2000,3000 for c and 4000,5000,8000 for d.i need
to find the sum of these accounts c and d individually
and find the differences between their sum using one select
statement.

Answer Posted / umesh naik

select a.amt1 c_sum ,b.amt2 d_sum
, a.amt1 - b.amt2 cd_diffrence
from
(select sum(amount) amt1 from one_table where account='c')
a,
(select sum(amount) amt2 from one_table where account='c') b












select (select sum(a.amount) from one a where
a.account='d')-(select sum(b.amount) from one b where
b.account='c') from dual;

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is pl sql a programming language?

524


What are the conditions an underlying table must satisfy before a cursor can be used by a positioned update or delete statement? : Transact sql

504


Write a sql query to get the third highest salary of an employee from employee_table?

608


What is trigger in sql and its types?

511


How do I quit sql?

463






What is sqlerrm?

517


What is data types in sql?

510


what is normalization? : Sql dba

541


What is right join in sql?

526


How do you create a db file?

491


how to write date and time literals? : Sql dba

511


difference between anonymous blocks and sub-programs.

597


How to create a menu in sqlplus or pl/sql?

583


What are the disadvantages of not performing database normalization?

569


what is try_catch block in procedure

1163