S) How to find dept wise 2nd and 3rd highest salary .

Sort : Dept-Asc 

Salary-Desc 

Scan 

Key –Dept 

Let decimal (“ “) rank =0; 

Type temporary type = 

Record 

Decimal(“|”) count ; 

End; 

Temp :: initialize(in)= 

Begin 

Temp. rank=0; 

Temp.count :: 0; 

End; 

Temp::scan(temp,in)= 

Begin 

Rank =(if(temp.count=in.sal)rank else rank +1; 

Temp.count  ::temp.count+1; 

End; 

Temp :: finalize(temp,in)= 

Begin 

Out.* ::in.* ; 

End; 

Out ::output_select(out)= 

Begin 

Out ::rank ==2 or rank ==3; 

End; 

 

Note :- If any dept doesn’t have 3 rd highest or 2nd highest then also above code will work , but in output that dept data will not come

 

 

 

 

 

Comments

Popular posts from this blog

T) For data parallelism, we can use partition components. For component parallelism, we can use replicate component. Like this which component(s) can we use for pipeline parallelism?

T) When to use sort within groups ?

T) Explain about on .abi-unc files in abinitio ?