Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.02 KB | None | 0 0
  1. SELECT users.name, journal.id, journal.package_id as package, journal.ts as `when`, journal.id as transactionId, journal.amount as stake
  2. FROM aen_marketplace_journal journal
  3.  
  4. INNER JOIN (
  5.     SELECT maxStake.package_id, MAX(maxStake.ts) ts, MAX(maxStake.id) id, SUM(maxStake.amount) totalStakes
  6.   FROM aen_marketplace_journal AS maxStake
  7.   WHERE maxStake.journal_code_id=28
  8.     AND month(maxStake.ts) = 09
  9.     AND year(maxStake.ts) = 2018
  10.   GROUP BY maxStake.package_id
  11. ) maxStake ON journal.id = maxStake.id AND journal.ts = maxStake.ts
  12.  
  13. LEFT JOIN aen_marketplace_packages AS packages ON packages.id = journal.package_id
  14. LEFT JOIN aen_users AS users ON users.id = journal.user_id
  15.  
  16. WHERE journal.journal_code_id=28
  17. AND month(journal.ts) = 09
  18. AND year(journal.ts) = 2018
  19. AND month(FROM_UNIXTIME(packages.auction_end_date/1000)) = 09
  20. AND year(FROM_UNIXTIME(packages.auction_end_date/1000)) = 2018
  21. AND ROUND(maxStake.totalStakes + packages.buyin * packages.bid_amount / 100 * packages.percentage_offered) = 0
  22. ORDER BY package DESC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement