Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Business and Economics Interviews:Account Manager AssistantAccountantAccounting ClerkAccounts ExecutiveAccounts OfficerAccounts Receivable (AR)AI AlgorithmsBPELBudgetingBusiness Development AssociateBusiness Development OfficerBusiness Development ResearcherBusiness Executive DevelopmentBusiness RatiosBusiness StrategyCA (Chartered Accountants)Change managementChief executive officer (CEO)Company Affairs (CS)Competitive StrategyCooperation SkillsCorporate StrategyCSCustomer ExperienceCustomer ServiceDeposit AccountEcommerce Customer Support ExecutiveEcommerce ManagerEconomicsExecutive International BusinessFinancialFixed AssetsGeneral AccountingGeneral LedgerGood SupervisorHospitality AccountingICWAImport Export SpecialistInsuranceIntegrated AuditsInventory AccountingInventory planning and controlManager Business UnitMerchandiserMergers & AcquisitionsNonprofit AccountingOrganizational IssuesOrganizational SkillsPayables ManagementPayroll ManagementPersonal AccountsPersonal Business AdviserPetty CashPrivate EquityProbation OfficerPublic relationsPurchase ExecutivePurchase PlannerPurchasing ManagerPurchasing OfficerQuality AuditsQuality MeasuresResearcher TraineeResponsibilityRetailRetaining Good EmployeesSecretary Accounts OfficerSenior Tax OfficerStrategy MethodsSuccessful StrategySweep AccountsTAX AccountantTaxationTransactional AccountsUser AccountWork Pressure
Copyright © 2018. All Rights Reserved
Business Development Officer Interview Question:
What is dense rank?
Submitted by: AdministratorThe DENSE_RANK function computes the rank of a row in an ordered group of rows. The ranks are consecutive integers beginning with 1. The largest rank value is the number of unique values returned by the query. Rank values are not skipped in the event of ties. Rows with equal values for the ranking criteria receive the same rank.
The DENSE_RANK function does not skip numbers and will assign the same number to those rows with the same value. Hence, after the result set is built in the inline view, we can simply select all of the rows with a dense rank of three or less, this gives us everyone who makes the top three salaries by department number.
ex:
Give me the set of sales people who make the top 3 salaries - that is, find the set of distinct salary amounts, sort them, take the largest three, and give me everyone who makes one of those values.
SELECT * FROM (
SELECT deptno, ename, sal,
DENSE_RANK()
OVER (
PARTITION BY deptno ORDER BY sal desc
) TopN FROM emp
)
WHERE TopN <= 3
ORDER BY deptno, sal DESC
/
DEPTNO ENAME SAL TOPN
---------- ---------- ---------- ----------
10 KING 5000 1
CLARK 2450 2
MILLER 1300 3
20 SCOTT 3000 1 <--- ! (in case of rank JONES will have 3 and dense rank will have 2)
FORD 3000 1 <--- !
JONES 2975 2
ADAMS 1100 3
30 BLAKE 2850 1
ALLEN 1600 2
30 TURNER 1500 3
Submitted by:
The DENSE_RANK function does not skip numbers and will assign the same number to those rows with the same value. Hence, after the result set is built in the inline view, we can simply select all of the rows with a dense rank of three or less, this gives us everyone who makes the top three salaries by department number.
ex:
Give me the set of sales people who make the top 3 salaries - that is, find the set of distinct salary amounts, sort them, take the largest three, and give me everyone who makes one of those values.
SELECT * FROM (
SELECT deptno, ename, sal,
DENSE_RANK()
OVER (
PARTITION BY deptno ORDER BY sal desc
) TopN FROM emp
)
WHERE TopN <= 3
ORDER BY deptno, sal DESC
/
DEPTNO ENAME SAL TOPN
---------- ---------- ---------- ----------
10 KING 5000 1
CLARK 2450 2
MILLER 1300 3
20 SCOTT 3000 1 <--- ! (in case of rank JONES will have 3 and dense rank will have 2)
FORD 3000 1 <--- !
JONES 2975 2
ADAMS 1100 3
30 BLAKE 2850 1
ALLEN 1600 2
30 TURNER 1500 3
Submitted by:
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.