Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to get fifth highest value from a column

A source table contains emp_name and salary columns.

I want to have a mapping to load all records with 5th highest salary into the target table.

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Here are the screenshots

0683p000009Lroz.jpgGeneral View0683p000009Lrcd.jpgMy source data0683p000009LroA.jpgSource Schema0683p000009Lrsu.jpgtSortRow config0683p000009Lrng.jpgtMap config with sequence0683p000009Lrt4.jpgFinal Results

View solution in original post

8 Replies
Anonymous
Not applicable
Author

The best option is making from the source, if your source is oracle you could make a query that returns you the 5 rows you need.

 

Also you could use a tSortRow component sorting column salary in desc order, then a tmap component where you declare a var with numeric sequence (using the internal talend function) from  value1 and increment by 1, and an output with a condition where you evaluates this variable and if its value is between 1 and 5 then the output is valid.

Anonymous
Not applicable
Author

Can u please attach some screenshots for clear understanding . Thanks in Advance

Anonymous
Not applicable
Author

Here are the screenshots

0683p000009Lroz.jpgGeneral View0683p000009Lrcd.jpgMy source data0683p000009LroA.jpgSource Schema0683p000009Lrsu.jpgtSortRow config0683p000009Lrng.jpgtMap config with sequence0683p000009Lrt4.jpgFinal Results

Anonymous
Not applicable
Author

Thank you very much

Anonymous
Not applicable
Author

Using tMap component we can get the Top 5th highest record. If you follow below steps in tMap component we will get only top 5th highest record. In this example I am taking top 5th salary paid from the employees.

Step-01: Below is the Job Flow, Using tSortRow and tMap components.0683p000009MaWy.jpg

 

Step-02: In the tSortRow component sort the data as mentioned below.

 

0683p000009MaXD.jpg

 

Step-03: In the tMap component, create the variables like

SeqID = Numeric.sequence("SID",1,1)  and in the Expression filter give the condition as Var.SeqID == 5.

0683p000009MaXN.jpg

 

Steo-04: Now run the job and see the output in the tLogRow component. We will only one record, which is top 5th salary from employees.

0683p000009MaXY.jpg

Anonymous
Not applicable
Author

Using tMap component we can get the Top 5th highest record. If you follow below steps in tMap component we will get only top 5th highest record. In this example I am taking top 5th salary paid from the employees.

Step-01: Below is the Job Flow, Using tSortRow and tMap components.0683p000009MaWy.jpg

 

Step-02: In the tSortRow component sort the data as mentioned below.

 

0683p000009MaXD.jpg

 

Step-03: In the tMap component, create the variables like

SeqID = Numeric.sequence("SID",1,1)  and in the Expression filter give the condition as Var.SeqID == 5.

0683p000009MaXN.jpg

 

Steo-04: Now run the job and see the output in the tLogRow component. We will only one record, which is top 5th salary from employees.

0683p000009MaXY.jpg

TRF
Champion II
Champion II

Much more easier, tFileInputDelimited-->tMap-->tSampleRow
TRF
Champion II
Champion II

Much more easier, tFileInputDelimited-->tMap-->tSampleRow