Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- query for cost by user by product
- SELECT u.name AS user_name, p.name AS product_name, SUM(tl.cost) AS cost
- FROM transaction_line tl
- INNER JOIN transactions t ON tl.transaction_id = t.id
- INNER JOIN users u ON t.user_id = u.id
- INNER JOIN products p ON tl.product_id = p.id
- GROUP BY u.id, p.id
- -- ZF2 Paginator Count turns it into
- SELECT COUNT(1)
- FROM transaction_line tl
- INNER JOIN transactions t ON tl.transaction_id = t.id
- INNER JOIN users u ON t.user_id = u.id
- INNER JOIN products p ON tl.product_id = p.id
- -- PULL Request turns it into
- SELECT COUNT(DISTINCT u.id, p.id)
- FROM transaction_line tl
- INNER JOIN transactions t ON tl.transaction_id = t.id
- INNER JOIN users u ON t.user_id = u.id
- INNER JOIN products p ON tl.product_id = p.id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement