I am using Django query to filter out some transactions from table where one transaction might have multiple entries in the table.
E.g. Sample table
+---------------+---------+
| TransactionId | Status |
+---------------+---------+
| Txn0 | Pending |
| Txn0 | Success |
| Txn1 | Fail |
| Txn2 | Pending |
| Txn3 | Fail |
| Txn4 | Pending |
| Txn4 | Fail |
| Txn5 | Pending |
+---------------+---------+
Current query :
SampleTable.objects.exclude(status='Fail').exclude(status='Success')
My current query returns Txn0
, Txn2
,Txn4
, Txn5
( because these are marked pending).
I need a queryset which return only row Txn2
, Txn5
( because all other transaction has atleast one Fail or Success transaction).
Also, tried using .distinct()
but that didn't help.