Guest User

Untitled

a guest
Aug 5th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1.  
  2.  
  3.  
  4. -- usage report
  5.  
  6. select connector_name, count(connector_name)
  7.  
  8. FROM dblink('dbname=trustfilestorage user=deploy password=4BFkh59jDd9YCSu',
  9. 'SELECT account_id, company_name, connector_name from company_daily_usage
  10. where
  11. created_at > date_trunc(''MONTH'',now())::DATE
  12. and usage = ''CONNECTOR_ACTIVE''
  13. GROUP BY connector_name, account_id, company_name
  14. ')
  15. AS usage(account_id INT, company_name TEXT, connector_name TEXT)
  16. JOIN merchants on merchants.account_id = usage.account_id
  17. LEFT OUTER JOIN subscriptions on subscriptions.account_id = merchants.account_id
  18. where email NOT LIKE '%test.%' and email NOT LIKE '%avalara%' and email NOT LIKE '%sush.io%'
  19. --and subscriptions.expired_at ISNULL
  20. --and subscriptions.cancelled_at ISNULL
  21. --and subscriptions.revoked_at ISNULL
  22. --and subscriptions.created_at > date_trunc('MONTH',now())::DATE
  23. GROUP BY usage.connector_name
  24. ORDER BY usage.connector_name
  25. ;
Add Comment
Please, Sign In to add comment