ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Databases  >>  SQL PLSQL
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
Question
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.
 Question Submitted By :: Charykkr
I also faced this Question!!     Rank Answer Posted By  
 
  Re: 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
# 1
SELECT SUM(C)-SUM(D) FROM TABLE_NAME;
 
Is This Answer Correct ?    3 Yes 1 No
Apurba
 
  Re: 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
# 2
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 ?    6 Yes 0 No
Bunty
 
 
 
  Re: 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
# 3
SELECT ABS(SUM(DECODE(ACCOUNTS,'C',AMOUNTS))-SUM(DECODE
(ACCOUNTS,'D',AMOUNTS))) FROM TEMP
 
Is This Answer Correct ?    0 Yes 1 No
Lalitha
 
  Re: 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
# 4
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 ?    6 Yes 0 No
Biswaranjan
 
  Re: 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
# 5
The question is not in proper grammar .. To me it looks like
what Biswaranjan interprets above
 
Is This Answer Correct ?    0 Yes 0 No
Priya
 
  Re: 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
# 6
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
Umesh Naik
 
  Re: 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
# 7
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 ?    1 Yes 0 No
Anuj Shukla
 
  Re: 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
# 8
I hope this will be helpful.

SELECT sum(Account) as "Account Sum", sum(Amount) as "Amount
Sum", sum(Amount)-sum(Account) as "Difference" FROM account
 
Is This Answer Correct ?    0 Yes 0 No
Sandeep
 

 
 
 
Other SQL PLSQL Interview Questions
 
  Question Asked @ Answers
 
What happens if a procedure that updates a column of table X is called in a database trigger of the same table ?  1
in materialized view the structure will create immediately or not? iFlex2
in a package one procedure is wrong package shows valid or not  3
what is constraining table?  1
What can be a size of a pl/sql block? Is there any limit?  2
how to retrive only second row from table? IBM15
What are the attributes of SQL*PLUS ? Oracle1
wht is the difference between truncat,drop in sqlserver wht is the difference between function and stored procedure Apollo3
How do you assign Construct the where clause without concatenating Field,value pairs? Microsoft1
What are user defined stored procedures ? BirlaSoft3
how to delete duplicate rows from a specified table(only single table) how do you know which join is need to be used UST8
what are the differences among these table level lock modes - IN SHARE MODE, IN SHARE UPDATE MODE, IN EXCLUSIVE MODE ? HCL2
If an unique key constraint on DATE column is created, will it validate the rows that are inserted with SYSDATE?  3
How do you retrieve set of records from database server. {Set max records = 100 & use paging where pager page no or records = 10 & after displaying 100 records again connect to database retrieve next 100 } DELL2
Can a view be updated/inserted/deleted?If Yes under what conditions?  3
How to return more than one value from a function? Satyam8
What is RAC in oracle?  3
what command is used to create a table by copying the structure of another table including constraints ? eicc4
how to retrieve only duplicate values in a table  2
how will u find statistics of a database objects? iFlex1
 
For more SQL PLSQL Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com