Lessons Learnt

Informatica Rank Transformation DC/ SC/ Geo/Practice: Siruseri Chennai Name of the project/support fn: BOA Name of the author: Ankit Kumar Date Created:16-Feb-2012 28 February 2012 .

2) Table 1: Employee Table We want to find out the Employees those are having salary equal to the highest salary in each department. EMPLOYEE_ID FIRST_NAME LAST_NAME DEPT_ID SALARY NOT NULL NOT NULL NOT NULL NUMBER(6) VARCHAR2(20) VARCHAR2(25) NUMBER(6) NUMBER(8. 28 February 2012 .Description Project Scenario Consider a table EMPLOYEE with the following structure.

Rank Transformation is used to find the highest salary (Group by DEPT_ID and order by SALARY). 4. The configuration done in Rank transformation is shown in figure. 3. 2. Top/Bottom Indicates the rank based on highest value/lowest value Number of ranks denotes the number of records to be returned for each partition or each group Figure 1: Rank Configuration 28 February 2012 .How it happened Process adopted 1.

Rank Transformation generates number of records equal to the value specified for number of rank 28 February 2012 . Causal  Number of Rank value is 1.Issues & analysis Issues faced  The rank transformation returned only one record for each DEPT even if the DEPT is having more than 1 employees those salary is equal to the highest salary of DEPT.

Results Before  For each DEPT the rank transformation returned only one record regardless the number of employees those salary is equal to highest salary. 28 February 2012 . After  For each DEPT all the records have been fetched where employee salary is equal to the highest salary.

salary. •The desired result can be obtain by the following query. dept_id.Solution Solution •Database analytic function can be used here. 28 February 2012 . first_name. last_name. SELECT * FROM (SELECT employee_id. •The analytic function used here is RANK() function. RANK() OVER(PARTITION BY dept_id ORDER BY salary DESC) Top FROM emp) WHERE Top <= 1.

k@tcs. Adopt any alternative choice like Analytic functions.com 28 February 2012 .How this may be prevented elsewhere Prevention When there are such scenarios where more than one records can have rank 1 and we want all the records to be fetched avoid using rank transformation. Contact Info : ankit11.

Sign up to vote on this title
UsefulNot useful