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
Can we use insert statement in function?
How do you modify a table in sql?
How can we avoid duplicating records in a query?
What is normalization in sql?
What has stored procedures in sql?
What are the possible values for the boolean data field?
How do you declare a variable in pl sql?
Does pdo prevent sql injection?
how is exception handling handled in mysql? : Sql dba
What is cursor status?
Is sqlexception checked or unchecked?
What is the benefit of foreign key?
Can we insert in view in sql?
What is primary key and foreign key?
Is left join and outer join same?