Advertisement
Guest User

Zend Paginator Count Issue Query

a guest
Jun 5th, 2013
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.79 KB | None | 0 0
  1. -- query for cost by user by product
  2. SELECT u.name AS user_name, p.name AS product_name, SUM(tl.cost) AS cost
  3.     FROM transaction_line tl
  4.     INNER JOIN transactions t ON tl.transaction_id = t.id
  5.     INNER JOIN users u ON t.user_id = u.id
  6.     INNER JOIN products p ON tl.product_id = p.id
  7.     GROUP BY u.id, p.id
  8.  
  9. -- ZF2 Paginator Count turns it into
  10. SELECT COUNT(1)
  11.     FROM transaction_line tl
  12.     INNER JOIN transactions t ON tl.transaction_id = t.id
  13.     INNER JOIN users u ON t.user_id = u.id
  14.     INNER JOIN products p ON tl.product_id = p.id
  15.  
  16. -- PULL Request turns it into
  17. SELECT COUNT(DISTINCT u.id, p.id)
  18.     FROM transaction_line tl
  19.     INNER JOIN transactions t ON tl.transaction_id = t.id
  20.     INNER JOIN users u ON t.user_id = u.id
  21.     INNER JOIN products p ON tl.product_id = p.id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement