Skip to content

Instantly share code, notes, and snippets.

@jblac
Created February 4, 2013 19:18
Show Gist options
  • Save jblac/4708858 to your computer and use it in GitHub Desktop.
Save jblac/4708858 to your computer and use it in GitHub Desktop.
$dql = "SELECT p.postDate, co.company_name,
COUNT(*) AS `postDatesScheduled`,
COUNT(IF(c.postDateChargedStatus_id > 1, 1, NULL)) AS `postDateReady`,
SUM( IF(c.postDateChargedStatus_id = 6, 1, NULL)) AS `postDatesCharged`,
SUM( IF(c.`fwCompletionDate`, 1, NULL)) AS `postDatesComplete`,
SUM( authOnlyAmount ) AS `fwPotential`,
SUM( IF(p.`fwfAuthed`, p.`authOnlyAmount`, NULL)) AS `fwCharged`,
SUM( IF(c.`fwCompletionDate`, p.`authOnlyAmount`, NULL)) AS `fwCapt`
FROM customer c
JOIN Purchase p ON p.customer_Id = c.Id
JOIN User u on c.salesRep_Id = u.Id
JOIN Company co on c.salesCompany_Id = co.Id
WHERE c.`saleType_Id` = 2".$comp."
AND p.postDate BETWEEN :beg AND :fin
GROUP BY p.postDate, c.salesCompany_Id
ORDER BY p.postDate ASC";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment