Skip to content

Instantly share code, notes, and snippets.

@parshap
Created December 19, 2013 08:26
Show Gist options
  • Save parshap/8036111 to your computer and use it in GitHub Desktop.
Save parshap/8036111 to your computer and use it in GitHub Desktop.
select sum(transactions.price) from sellers
left join products on products.seller_id = sellers.id
left join purchases on purchases.product_id = products.id
left join transactions on transactions.purchase_id = purchases.id
where sellers.id = SELLER_ID and
transactions.is_payed = 0 and
transactions.date <= date_sub(now(), interval 1 week)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment