a guest Jun 26th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT COUNT(tr.ticketnum) AS 'Product tickets by Rep', tp.prodcode, tr.repid, (COUNT(tp2.compprodtick)/COUNT(tp.prodcode)) AS 'Percent'
  2. FROM TicketRep AS tr
  3. JOIN TicketProduct AS tp
  4.  ON tr.ticketnum = tp.ticketnum
  5. JOIN
  6. (SELECT prodcode, COUNT(prodcode) AS 'compprodtick'
  7. FROM TicketProduct
  8. GROUP BY prodcode) AS tp2
  9. ON tp.prodcode = tp2.prodcode
  10.  GROUP BY tp.prodcode, tr.repid;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand