Skip to content

Instantly share code, notes, and snippets.

@dmexe
Created November 26, 2012 14:42
Show Gist options
  • Save dmexe/4148556 to your computer and use it in GitHub Desktop.
Save dmexe/4148556 to your computer and use it in GitHub Desktop.
copy (select dsc.sfid, count(c.id), sum(d.cost) from deal_source_sf_deal_containers dsc inner join deal_source_sf_deals ds on ds.deal_source_sf_deal_container_id = dsc.id inner join deals d on d.deal_source_sf_deal_id = ds.id inner join coupons c on c.deal_id = d.id and c.state = 'money_back' group by dsc.sfid) to '/tmp/returns.csv' with csv;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment