Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT users.name, journal.id, journal.package_id as package, journal.ts as `when`, journal.id as transactionId, journal.amount as stake
- FROM aen_marketplace_journal journal
- INNER JOIN (
- SELECT maxStake.package_id, MAX(maxStake.ts) ts, MAX(maxStake.id) id, SUM(maxStake.amount) totalStakes
- FROM aen_marketplace_journal AS maxStake
- WHERE maxStake.journal_code_id=28
- AND month(maxStake.ts) = 09
- AND year(maxStake.ts) = 2018
- GROUP BY maxStake.package_id
- ) maxStake ON journal.id = maxStake.id AND journal.ts = maxStake.ts
- LEFT JOIN aen_marketplace_packages AS packages ON packages.id = journal.package_id
- LEFT JOIN aen_users AS users ON users.id = journal.user_id
- WHERE journal.journal_code_id=28
- AND month(journal.ts) = 09
- AND year(journal.ts) = 2018
- AND month(FROM_UNIXTIME(packages.auction_end_date/1000)) = 09
- AND year(FROM_UNIXTIME(packages.auction_end_date/1000)) = 2018
- AND ROUND(maxStake.totalStakes + packages.buyin * packages.bid_amount / 100 * packages.percentage_offered) = 0
- ORDER BY package DESC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement