I have 2 tables, shopOrder and wholesaleOrder, each have the following structure:
Expand|Select|Wrap|Line Numbers
- orderID, orderDate, orderTotal
Expand|Select|Wrap|Line Numbers
- Date, Number of Wholesale Orders, Wholesale Orders Total, Number of Shop Orders, Shop Orders Total
[HTML]<table>
<thead>
<tr>
<th>Date</th>
<th>Number of Wholesale Orders</th>
<th>Wholesale Orders Total</th>
<th>Number of Shop Orders</th>
<th>Shop Orders Total</th>
</tr>
</thead>
<tbody>
<tr>
<td>11/05/2008</td>
<td>1</td>
<td>100.00</td>
<td>2</td>
<td>50.00</td>
</tr>
<tr>
<td>13/05/2008</td>
<td>0</td>
<td>0</td>
<td>4</td>
<td>130.00</td>
</tr>
<tr>
<td>14/05/2008</td>
<td>3</td>
<td>37.00</td>
<td>0</td>
<td>0</td>
</tr>
</tbody>
</table>[/HTML]
Any help with the SQL query would be greatly appreciated! Here is my current query:
Expand|Select|Wrap|Line Numbers
- SELECT wholesaleOrder.orderDate,
- SUM(wholesaleOrder.orderTotal) AS wholesaleOrdersTotal,
- COUNT(wholesaleOrder.orderID) AS wholesaleOrdersQuantity
- SUM(shopOrder.orderTotal) AS shopOrdersTotal,
- COUNT(shopOrder.orderID) AS shopOrdersQuantity
- FROM wholesaleOrder
- LEFT JOIN shopOrder ON shopOrder.orderDate=wholesaleOrder.orderDate
- WHERE wholesaleOrder.orderDate BETWEEN $date1 AND $date2
- OR shopOrder.orderDate BETWEEN $date1 AND $date2
- GROUP BY wholesaleOrder.orderDate
Alex