Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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.

Answers were Sorted based on User's Feedback



i have one table with accounts and amounts as colums.accounts with columns c and d. and amounts wit..

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

i have one table with accounts and amounts as colums.accounts with columns c and d. and amounts wit..

Answer / biswaranjan

this works good for the query


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 ?    11 Yes 1 No

i have one table with accounts and amounts as colums.accounts with columns c and d. and amounts wit..

Answer / apurba

SELECT SUM(C)-SUM(D) FROM TABLE_NAME;

Is This Answer Correct ?    8 Yes 6 No

i have one table with accounts and amounts as colums.accounts with columns c and d. and amounts wit..

Answer / anuj shukla

Hi all,
question simply ask for the total of both the columns and
their difference, all in one 'select' statement.

select sum(c)"Sum of C",sum(d)"Sum Of
D",abs(sum(c)-sum(d))"Difference" from accountA

Is This Answer Correct ?    4 Yes 2 No

i have one table with accounts and amounts as colums.accounts with columns c and d. and amounts wit..

Answer / lalitha

SELECT ABS(SUM(DECODE(ACCOUNTS,'C',AMOUNTS))-SUM(DECODE
(ACCOUNTS,'D',AMOUNTS))) FROM TEMP

Is This Answer Correct ?    2 Yes 2 No

i have one table with accounts and amounts as colums.accounts with columns c and d. and amounts wit..

Answer / akki julak

SELECT SUM(C),SUM(D),SUM(C)-SUM(D) 'difference'
FROM accounts;

Is This Answer Correct ?    3 Yes 3 No

i have one table with accounts and amounts as colums.accounts with columns c and d. and amounts wit..

Answer / priya

The question is not in proper grammar .. To me it looks like
what Biswaranjan interprets above

Is This Answer Correct ?    0 Yes 1 No

i have one table with accounts and amounts as colums.accounts with columns c and d. and amounts wit..

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

i have one table with accounts and amounts as colums.accounts with columns c and d. and amounts wit..

Answer / vijay sinha

select (select sum(amount) from table_name where account = 'C') - (select sum(amount) from table_name where account = 'D')

Is This Answer Correct ?    0 Yes 1 No

i have one table with accounts and amounts as colums.accounts with columns c and d. and amounts wit..

Answer / ankur maheshwari

select abs(sum(c1.amounts)-sum(d1.amounts)) 'Amount
difference' from account c1, account d1 where
c1.accounts='c' and d1.accounts='d'

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More SQL PLSQL Interview Questions

What are the string functions in sql?

0 Answers  


What does the acronym acid stand for in database management?

0 Answers  


how to implement one-to-one, one-to-many and many-to-many relationships while designing tables? : Sql dba

0 Answers  


I Have A Table Like This. Cityno Cityname Mails 1 Bangalore 8km 2 Hsr Layout 20km 3 Mejistic 30km 4 Jayadeva 55km 5 Itpl 80km 6 Hebbal 115km I Have Data Like This I Want O/p Like This Distance No.ofcity 0-50km 3 51-100km 2 101-150km 4 And So On

6 Answers   DELL, HCL, Oracle,


What has stored procedures in sql and how we can use it?

0 Answers  


what is the use of double ampersand (&&) in sql queries?

0 Answers  


How to add Foreign key in a table after the creation of the table?

5 Answers   Satyam,


What is raw datatype in sql?

0 Answers  


Can function return multiple values in sql?

0 Answers  


write a query to delete similar records in particular fields(columns) in different tables

6 Answers   TCS,


What is sqlexception in java?

0 Answers  


in oracle 10g sw after compiling procedure how to pass parameter values ,if we (v_empid out number)how to give empid after successful compilation program.This site exact suitable for 10g with respect to question & answer same format , im trying sql browser & sql command prompt using exec procedure name & respective parameters.

0 Answers  


Categories