Request: the top 3 customers by total spend, as {customer, spend}
Input:
customer: A
total: 40
customer: B
total: 10
customer: A
total: 25
customer: C
total: 90
customer: D
total: 5
jq program: group_by(.customer) | map({customer: .[0].customer, spend: (map(.total) | add)}) | sort_by(-.spend) | .[0:3]
Output:
customer: C
spend: 90
customer: A
spend: 65
customer: B
spend: 10