Clients whose sales are among the top 15 over the years

Get the sales data from the SALES database table, and find the clients whose sales in each year always are among the top 15

Solution:

A
1
=demo.query("select * from SALES")
2
=A1.group(year(ORDERDATE))
3
=A2.(~.group(CLIENT))
4
=A3.(~.new(CLIENT,~.sum(AMOUNT):Amount))
5
=A4.(~.sort@z(Amount).select(#<=15))
6
=A5.(~.(CLIENT))
7
=A6.isect()

The computation in A7 is shown below: