<html><head></head><body>Subqueries:<br>
SELECT (SELECT ...), (SELECT ...) FROM ...<br>
<br>
If they don&#39;t work, upgrade to a newer version of MariaDB.  (If this is the customer I assume it is, use RackSpace&#39;s IUS repo to upgrade).<br>
<br>
Alternately, create two VIEWs, one for each aggregate count, and OUTER JOIN them.<br>
-Adam<br>
<br><br><div class="gmail_quote">On March 24, 2016 9:16:31 AM CDT, Trevor Cordes &lt;trevor@tecnopolis.ca&gt; wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">Can anyone help me figure out how to do this in SQL (MySQL)?<br /><br />(pseudo-code giving you the gist):<br /><br />SELECT custid, (count orders where ttl=X), (count orders where ttl=Y)<br />FROM ordertable<br />GROUP BY custid;<br /><br /><br />I basically want to count two different things based on two different <br />wheres.  If I put in a where clause then I select either the X or the Y <br />but I can't seem to get both in such a way I can count the X's and Y's.  I <br />tried thinking about unions but couldn't make it work.  I want to do this <br />all in 1 query as I want the sorted union of all custid's (X and Y).<br /><br />P.S. ordertable has/can have multiple entries for each custid.<br /><br />Ideas are appreciated!<br /><hr /><br />Roundtable mailing list<br />Roundtable@muug.mb.ca<br /><a href="http://www.muug.mb.ca/mailman/listinfo/roundtable">http://www.muug.mb.ca/mailman/listinfo/roundtable</a><br /></pre></blockquote></div><br>
-- <br>
Sent from my Android device with K-9 Mail. Please excuse my brevity.</body></html>