So here is what I am trying to accomplish. I have a single table, transactions, that has multiple entries of a sessionId with transactionCodes. I am trying to count distinct SessionId's only if they do not contain a specific transCode.
So basically transactions could look like:
sessionId transcode
1 100
1 101
1 102
2 100
2 101
2 102
2 103
What I need to do is along these lines.
select count(distinct sessionId) where transCode != 103;
I would expect the above to only return a single record but in practice it obviously does not because my novice level SQL query returns me far more records than it should!