How would I combine these two queries into 1 and to run efficiently on a large table?
SELECT field1, count(1) as requestCount
FROM table1
WHERE date_complete >= '2012-06-12 00:00:00'
AND date_complete <= '2012-07-12 23:59:59'
GROUP BY field1
SELECT field2, count(1) as completeCount
FROM table1
WHERE date_complete >= '2012-06-12 00:00:00'
AND date_complete <= '2012-07-12 23:59:59'
GROUP BY field2
Table holds information for a process where multiple users are involved. For example say the first person creates the request, second person completes the request and the third closes out the request by filing it.
I want to count how many each user requested, completed and filed in a specific time frame
I want these two combined to look like
+----------------+--------------+
| field1 | requestCount |
+----------------+--------------+
| PJB | 1 |
| RFD | 6 |
| YAS | 4 |
+----------------+--------------+
+
+---------+---------------+
| field2 | completeCount |
+---------+---------------+
| PJB | 4 |
| YAS | 5 |
+---------+---------------+
=
+----------------+--------------+---------------+
| Username | requestCount | completeCount |
+----------------+--------------+---------------+
| PJB | 1 | 4 |
| RFD | 6 | 0 |
| YAS | 4 | 5 |
+----------------+--------------+---------------+
UNION ALLbetween them.