Skip to content

Commit

Permalink
Refactor SQL query for revenue ranking
Browse files Browse the repository at this point in the history
This change updates the query to use `derived_addresses.address` instead of `fleets.address` and simplifies join conditions. The grouped column and join statements have been adjusted to improve query clarity and readability.
  • Loading branch information
billettc committed Sep 17, 2024
1 parent 5c6dbac commit 7047329
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions dbt/hivemapper/models/example/dbt_driver_and_revenu.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

select
RANK() OVER(ORDER BY SUM(ap.fleet_payment) DESC) rank,
f.address,
da.address,
sum(ap.fleet_payment) as honey,
sum(ap.fleet_usd_payment) as USD
from hivemapper.fleets f
inner join hivemapper.derived_addresses da on da.address = f.address
inner join hivemapper.dbt_all_payments ap on ap.payee_address = da.derivedaddress
group by f.address
from hivemapper.dbt_all_payments ap
inner join hivemapper.derived_addresses da on da.derivedaddress = ap.payee_address
group by da.address

0 comments on commit 7047329

Please sign in to comment.