L4 SQL
Bargains and Budget-Busters
FinOps is auditing cloud spend region by region. Two systems record line items: the provider's cost ledger and the team's internal allocations. Treat them as one combined stream of line items. For each region, name the service behind the single biggest line item and the service behind the single smallest. If two line items tie, take the one whose service name comes first alphabetically. Return one row per region with the region, its biggest spender, and its cheapest line item.
cloud_costs
cost_idINTEGER
providerTEXT
svc_nameTEXT
regionTEXT
amountREAL
acct_idTEXT
bill_dateTEXT
cost_allocs
alloc_idINTEGER
team_nameTEXT
svc_nameTEXT
regionTEXT
amountREAL
periodTEXT
acct_idTEXT
categoryTEXT
Write either SQL or Spark
Interviewer
I