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 / bunty

Hi,
I dont know if this is a intended way for which interviewer
has asked, but it will definitely give an answer,

select (select sum(value) from test_tab where parent='D')-
(select sum(value) from test_tab where parent='C')
difference from dual;

Cheers,
Bunty

Is This Answer Correct ?    13 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to create a new table in mysql? : Sql dba

546


how is exception handling handled in mysql? : Sql dba

549


What is rownum?

536


What are different functions in sql?

515


How do I run a sql query?

528






What is meaning of <> in sql?

585


Explain what is rdbms?

580


How to write html code in pl sql?

580


What are secondary keys?

559


how to calculate expressions with sql statements? : Sql dba

528


What is foreign key and example?

514


What are the advantages of sql? Explain

648


What action do you have to perform before retrieving data from the next result set of a stored procedure ?

2093


What makes a good primary key?

519


Why are indexes and views important to an organization?

527