Top rank per group: Difference between revisions

Line 5,821:
Kim Arlich E10001 57000
Timothy Grove E16398 29900</pre>
 
 
 
=={{header|Transd}}==
<lang scheme>
#lang transd
 
MainModule: {
table : String(
`@key_EmployeeName,EmployeeID,Salary,Department
"Tyler Bennett", "E10297",32000,"D101"
"John Rappl", "E21437",47000,"D050"
"George Woltman", "E00127",53500,"D101"
"Adam Smith", "E63535",18000,"D202"
"Claire Buckman", "E39876",27800,"D202"
"David McClellan","E04242",41500,"D101"
"Rich Holcomb", "E01234",49500,"D202"
"Nathan Adams", "E41298",21900,"D050"
"Richard Potter", "E43128",15900,"D101"
"David Motsinger","E27002",19250,"D202"
"Tim Sampair", "E03033",27000,"D101"
"Kim Arlich", "E10001",57000,"D190"
"Timothy Grove", "E16398",29900,"D190"`),
 
N: 2,
_start: (λ (with base TSDBase()
(load-table base table)
(build-index base "Department")
(with rows (tsd-query base select ["Department"] distinct)
(for row in rows do
(with recs (tsd-query base select all
where (lambda Department String() (eq Department (get row 0)))
sortby "Salary" desc limit N)
(for rec in recs do (textout rec "\n")))))
))
}</lang>{{out}}
<pre>
[D101, E00127, George Woltman, 53500]
[D101, E04242, David McClellan, 41500]
[D190, E10001, Kim Arlich, 57000]
[D190, E16398, Timothy Grove, 29900]
[D202, E01234, Rich Holcomb, 49500]
[D202, E39876, Claire Buckman, 27800]
[D050, E21437, John Rappl, 47000]
[D050, E41298, Nathan Adams, 21900]
</pre>
 
=={{header|TUSCRIPT}}==
111

edits