Professional Documents
Culture Documents
DataWareHouse/ETL
TESTING
Sunday,26August2012
Followers
SQLInterviewQuestionsand Followers(23)Next
AnswersPart1
Q)ihaveemptableinwhichcolumnsareempid,empname,salnowiwantto
increasethesaloftheparticularempwhosesalis<10000with2000RS&sal
>10000&<20000with4000RSandwhosesalis>20000with5000RSnow
writeasingleupdatequery.
UPDATEEmp Follow
SETsal=sal+
CASE
WHENsal>=1000ANDsal<2000THEN200
WHENsal>=2000ANDsal<3000THEN300 BlogArchive
END
2012(47)
1. The following query retrieves "2" highest paid employees FROM August(43)
each Department :
WhatisDataWarehouse?
DifferencebetweenDatabase
Total 1980 1981 1982 1983 andDataWarehouseTes...
ETLTestingProcess:
ETLTestingTechniques:
14 1 10 2 1
ETLorDatawarehouse
testing
SELECT COUNT (*), COUNT(DECODE(TO_CHAR (hiredate, UpdateStrategy
'YYYY'),'1980', empno)) "1980", Transformation
http://dwhtest.blogspot.in/2012/08/sqlinterviewquestionsandanswers.html 1/9
5/17/2017 DataWareHouse/ETLTESTING:SQLInterviewQuestionsandAnswersPart1
FilterTransformation
OUTPUT :
AggregatorTransformation
=======
DEPTNO ENAME SAL SUM (SAL) JoinerTransformation
========= ======= ==== =========
UnionTransformation
10 KING 5000 11725
30 BLAKE 2850 10900 Whataretheactiveand
passivetransformations?
10 CLARK 2450 11725
10 JONES 2975 11725 TypesofTesting
30 MARTIN 1250 10900 TestCase
30 ALLEN 1600 10900
Bug/DefectLifeCycle
30 TURNER 1500 10900
30 JAMES 950 10900 DefectTrackingFormat
30 WARD 2750 10900
Vmodel
20 SMITH 8000 33000
20 SCOTT 3000 33000 TestDesignPlan
20 MILLER 20000 33000 SoftwareRequirements
Specification(SRS)
4. Create a matrix query to display the job, the salary for that job SQLInterviewQuestionsand
based on department number, and the total salary for that job for AnswersPart1
all departments, giving each column an appropriate heading.
SQLInterviewQuestionsand
Answerspart2
The output is as follows we need to stick to this format :
SQLInterviewQuestionsand
AnswersPart3
Job Dept 10 Dept
ETLTestinglifecycle
20 Dept 30 Total
SQLInterviewQuestionsand
AnswersPartt4
ANALYST SQLInterviewQuestionsand
6000 6000 AnswersPart5
CLERK 1300 SQLInterviewQuestionsand
1900 950 4150 AnswersPart6
MANAGER 2450
SQLInterviewQuestionsand
2975 2850 8275 AnswersPart7
PRESIDENT
SQLInterviewQuestionsand
5000
AnswersPart8
5000
SALESMAN September(4)
5600 5600
AboutMe
http://dwhtest.blogspot.in/2012/08/sqlinterviewquestionsandanswers.html 2/9
5/17/2017 DataWareHouse/ETLTESTING:SQLInterviewQuestionsandAnswersPart1
SELECT job "Job", SUM (DECODE (deptno, 10, sal)) "Dept 10", leelabattu
SUM (DECODE (deptno, 20, sal)) "Dept 20", Follow 2
7. Tree Query :
SELECT *
FROM emp
WHERE (ROWID,0) IN (SELECT ROWID, MOD(ROWNUM,4)
FROM emp)
10. Top N rows FROM a table : (Displays top 9 salaried people)
http://dwhtest.blogspot.in/2012/08/sqlinterviewquestionsandanswers.html 3/9
5/17/2017 DataWareHouse/ETLTESTING:SQLInterviewQuestionsandAnswersPart1
SELECT
f2,
COUNT(DECODE(greatest(f1,59), least(f1,100), 1, 0)) "Range
60100",
COUNT(DECODE(greatest(f1,30), least(f1, 59), 1, 0)) "Range
3059",
COUNT(DECODE(greatest(f1,29), least(f1, 0), 1, 0)) "Range
0029"
FROM my_table
GROUP BY f2
SELECT num
FROM satyam
GROUP BY num
HAVING COUNT(*) > 1
16. Query for getting the following output as many number of rows
in the table :
http://dwhtest.blogspot.in/2012/08/sqlinterviewquestionsandanswers.html 4/9
5/17/2017 DataWareHouse/ETLTESTING:SQLInterviewQuestionsandAnswersPart1
**
***
****
*****
SELECT RPAD(DECODE(temp,temp,'*'),ROWNUM,'*')
FROM srinu1
FUNCTION F_BALANCE_VALUE
(p_business_group_id number, p_payroll_action_id number,
p_balance_name varchar2, p_dimension_name varchar2) RETURN
NUMBER
IS
l_bal number
l_defined_bal_id number
l_assignment_action_id number
BEGIN
SELECT assignment_action_id
INTO l_assignment_action_id
FROM
pay_assignment_actions
WHERE
assignment_id = :p_assignment_id
AND payroll_action_id = p_payroll_action_id
SELECT
defined_balance_id
INTO
l_defined_bal_id
FROM
pay_balance_types pbt,
pay_defined_balances pdb,
pay_balance_dimensions pbd
WHERE
pbt.business_group_id = p_business_group_id
AND UPPER(pbt.balance_name) = UPPER(p_balance_name)
AND pbt.business_group_id = pdb.business_group_id
AND pbt.balance_type_id = pdb.balance_type_id
AND UPPER(pbd.dimension_name) =
UPPER(p_dimension_name)
AND pdb.balance_dimension_id = pbd.balance_dimension_id
l_bal :=
pay_balance_pkg.get_value(l_defined_bal_id,l_assignment_action_id)
RETURN (l_bal)
exception
WHEN no_data_found THEN
RETURN 0
END
http://dwhtest.blogspot.in/2012/08/sqlinterviewquestionsandanswers.html 5/9
5/17/2017 DataWareHouse/ETLTESTING:SQLInterviewQuestionsandAnswersPart1
FUNCTION f_element_value(
p_classification_name in varchar2,
p_element_name in varchar2,
p_business_group_id in number,
p_input_value_name in varchar2,
p_payroll_action_id in number,
p_assignment_id in number
)
RETURN number
IS
l_element_value number(14,2) default 0
l_input_value_id pay_input_values_f.input_value_id%type
l_element_type_id pay_element_types_f.element_type_id%type
BEGIN
SELECT DISTINCT element_type_id
INTO l_element_type_id
FROM pay_element_types_f pet,
pay_element_classifications pec
WHERE pet.classification_id = pec.classification_id
AND upper(classification_name) =
upper(p_classification_name)
AND upper(element_name) =
upper(p_element_name)
AND pet.business_group_id = p_business_group_id
SELECT input_value_id
INTO l_input_value_id
FROM pay_input_values_f
WHERE upper(name) = upper(p_input_value_name)
AND element_type_id = l_element_type_id
SELECT NVL(prrv.result_value,0)
INTO l_element_value
FROM pay_run_result_values prrv,
pay_run_results prr,
pay_assignment_actions paa
WHERE prrv.run_result_id = prr.run_result_id
AND prr.assignment_ACTION_ID = paa.assignment_action_id
AND paa.assignment_id = p_assignment_id
AND input_value_id = l_input_value_id
AND paa.payroll_action_id = p_payroll_action_id
RETURN (l_element_value)
exception
WHEN no_data_found THEN
RETURN 0
END
SELECT ename,
NVL(LENGTH(REPLACE(TRANSLATE(UPPER(RTRIM(ename)),'ABCDEF
GHIJKLMNOPQRSTUVWXYZ'' ',' @'),' ',''))+1,1)
word_length
FROM emp
http://dwhtest.blogspot.in/2012/08/sqlinterviewquestionsandanswers.html 6/9
5/17/2017 DataWareHouse/ETLTESTING:SQLInterviewQuestionsandAnswersPart1
Explanation :
TRANSLATE(UPPER(RTRIM(ename)),'ABCDEFGHIJKLMNOPQRSTUVW
XYZ'' ',' @') This will translate all the characters
FROM AZ including a single quote to a space. It will also translate a
space to a @.
REPLACE(TRANSLATE(UPPER(RTRIM(ename)),'ABCDEFGHIJKLMNOP
QRSTUVWXYZ'' ',' @'),' ','') This will replace every
space with nothing in the above result.
LENGTH(REPLACE(TRANSLATE(UPPER(RTRIM(ename)),'ABCDEFGHIJ
KLMNOPQRSTUVWXYZ'' ',' @'),' ',''))+1 This will give
u the count of @ characters in the above result.
Postedbyleelabattuat10:28:00pm
+1 Recommend this on Google
Labels:SQL
7comments:
TekClasses 21September2015at15:48
Thiswasreallyagoodpostandalsoveryinformative.formoredetails
http://www.tekclasses.com/
Reply
TekClasses 21September2015at16:04
Infoisverygood..Veryinformativearticlepost.formoredetails
http://www.tekclasses.com/
Reply
http://dwhtest.blogspot.in/2012/08/sqlinterviewquestionsandanswers.html 7/9
5/17/2017 DataWareHouse/ETLTESTING:SQLInterviewQuestionsandAnswersPart1
Reply
TekClasses 21September2015at16:28
Yourblogisreallyuseful.Thanksforsharingthisuseful
blog..Supposeifanyoneinterestedtolearn
http://www.tekclasses.com/
Reply
Interviewquestionsanswerspdf 10June2016at17:16
DataWarehousingInterviewQuestionsandAnswers
http://allinterviewquestionsandanswerspdf.blogspot.in/2016/06/top100
datawarehousinginterview.html
Reply
PradeepReddy 12September2016at15:35
Very good collection of question and answers thank you for sharing this
article.KnowmoreaboutETLTestingTraining
Reply
PradeepReddy 12September2016at15:35
Very good collection of question and answers thank you for sharing this
article.KnowmoreaboutETLTestingTraining
Reply
EmergersTechnologies 21April2017at17:18
Just found your post by searching on the Google, I am Impressed and
LearnedLotofnewthingfromyourpost.Iamnewtobloggingandalways
try to learn new skill as I believe that blogging is the full time job for
learningnewthingsdaybyday.
"EmergersTechnologies"
Reply
Enteryourcomment...
Publish Preview Notifyme
http://dwhtest.blogspot.in/2012/08/sqlinterviewquestionsandanswers.html 8/9
5/17/2017 DataWareHouse/ETLTESTING:SQLInterviewQuestionsandAnswersPart1
Subscribeto:PostComments(Atom)
TotalPageviews
59,595
SearchThisBlog
Search
sri.Watermarktheme.PoweredbyBlogger.
http://dwhtest.blogspot.in/2012/08/sqlinterviewquestionsandanswers.html 9/9