I have a database (table1) with:
ID |
Name |
Status |
1 |
John |
Accepted |
2 |
John |
Removed |
3 |
John |
Transferred |
4 |
William |
Transferred |
I want a table where I count the number of times someone is in the database, but don't count the status status accepted. The results should be:ID |
Name |
Status |
# rows without status accepted |
1 |
John |
Accepted |
0 |
2 |
John |
Removed |
2 |
3 |
John |
Transferred |
2 |
4 |
William |
Transferred |
1 |
I have the following query:
Code:
xxx
LEFT JOIN
(SELECT [table1].[id], [table1].[name], [table1].[status], COUNT(*) as [Number rejected]
FROM [table1]
WHERE [table1].[status] <> "Accepted"
GROUP BY [table1].[id], [table1].[name], [table1].[status]
) as SubQuery1
ON ([table1].[id] = SubQuery1.[id] AND [table1].[name] = SubQuery1.[name] AND [table1].[status] = SubQuery1.[status]))
However, the problem is that with this query all rows with status "accepted" are removed. What do I wrong?