Question: I am using Access 2007 and I ran into a SQL statement that's got me confused. I was hoping to use a union in order to compare to SQL statements in three columns. I intend for it to look something like this: 
![Mockup](https://i.imgur.com/S1hoY6Y.png)

The two queries are very similar. By themselves, each query works just as I'd expect. If combined into a single query, I only get 2 columns rather than the expected 3.

\*\*Note: I added in the Type column for my own debugging\*

```
(SELECT ManufacturingRequest.reqDate, COUNT(ManufacturingRequest.reqID) AS Resolved
FROM ManufacturingRequest 
INNER JOIN QualityAssuranceApproval ON 
  ManufacturingRequest.reqID = QualityAssuranceApproval.reqID
WHERE 
  (QualityAssuranceApproval.qualityApproval AND[mfgApproval] = True) AND
  ManufacturingRequest.reqDate IS NOT NULL
GROUP BY ManufacturingRequest.reqDate
ORDER BY ManufacturingRequest.reqDate)

UNION ALL

(SELECT ManufacturingRequest.reqDate, COUNT(ManufacturingRequest.reqID) AS Unresolved
FROM ManufacturingRequest 
INNER JOIN QualityAssuranceApproval ON 
  ManufacturingRequest.reqID = QualityAssuranceApproval.reqID
WHERE 
  (QualityAssuranceApproval.qualityApproval AND[mfgApproval] = False) OR
  ManufacturingRequest.reqDate IS NOT NULL
GROUP BY ManufacturingRequest.reqDate
ORDER BY ManufacturingRequest.reqDate)

```

Here's the result set that I end up with. 

\*\*Note: I just included the type column in order to tell the difference between the 2 sets of data. It's merely for debugging.\*

![Results](https://i.imgur.com/iU9igjF.png)

What changes need to be made in order to create a Resolved vs Unresolved result? Thank you for any help you can provide.

Answer: 
You don't need a union here, you need three column, and the count in the second and third column should be conditional:

```
SELECT ManufacturingRequest.reqDate, 
        COUNT( CASE WHEN [mfgApproval] = True THEN ManufacturingRequest.reqID ELSE null END ) AS Resolved,
        COUNT( CASE WHEN [mfgApproval] = False THEN ManufacturingRequest.reqID ELSE null END ) AS Unresolved
FROM ManufacturingRequest INNER JOIN QualityAssuranceApproval ON ManufacturingRequest.reqID = QualityAssuranceApproval.reqID
WHERE (QualityAssuranceApproval.qualityApproval AND) AND ManufacturingRequest.reqDate IS NOT NULL
GROUP BY ManufacturingRequest.reqDate
ORDER BY ManufacturingRequest.reqDate

```

Good luck!
If you want to three columns you should add 3th column to both quires as below

```
(SELECT ManufacturingRequest.reqDate, COUNT(ManufacturingRequest.reqID) AS Resolved, null  AS Unresolved
FROM ManufacturingRequest INNER JOIN QualityAssuranceApproval ON ManufacturingRequest.reqID = QualityAssuranceApproval.reqID
WHERE (QualityAssuranceApproval.qualityApproval AND[mfgApproval] = True) AND ManufacturingRequest.reqDate IS NOT NULL
GROUP BY ManufacturingRequest.reqDate
ORDER BY ManufacturingRequest.reqDate)

UNION ALL

(SELECT ManufacturingRequest.reqDate, null AS Resolved, COUNT(ManufacturingRequest.reqID) AS Unresolved
FROM ManufacturingRequest INNER JOIN QualityAssuranceApproval ON ManufacturingRequest.reqID = QualityAssuranceApproval.reqID
WHERE (QualityAssuranceApproval.qualityApproval AND[mfgApproval] = False) AND ManufacturingRequest.reqDate IS NOT NULL
GROUP BY ManufacturingRequest.reqDate
ORDER BY ManufacturingRequest.reqDate)

```