I have the following SQL expression:
select id, count(oID) from MyTable group by oID;
and I get something like
+-------+---------------+
| id | count(oID) |
+-------+---------------+
| 002 | 6 |
| 104 | 1 |
| 101 | 1 |
| 908 | 1 |
+-------+---------------+
And now I’d like to pull out the rows (select id) where count(oID) is 1. How can I do this in one SQL statement?
Use a
HAVINGclause to filter an aggregated column.UPDATE 1
wrap the results in a subquery