I have a table employee that has employee’s benefit data.
I have a field in the table called isenrolled if field is 1 that means employee has enrolled for benefit and if field is 0 that means not enrolled.
My problem is i have multiple recs of a employee, that means Scott has two entries with isenrolled =1 and isenrolled =0.
I want to select only one rec of SCOTT where his isenrolled =1 and reject the one where isenrolled =0, that way i will get only unique recs for employees who has enrolled and who has not enrolled. How do i select those employees? I tried the qry below and it doesn’t work
select * FROM employee e
WHERE e.empid not IN( SELECT empid FROM employee e2
WHERE e2.isenrolled =1)
First I set up some test data using:
At this point the t4 table has now two records for each employee (one where isenrolled = 0 and one where isenrolled = 1)

so I change ALLEN’s data so he has “opted” out
This query then shows the data for ALLEN (1 record) and SMITH (2 records)
Then to show just one record per employee (restricted to ALLEN and SMITH in this case) you could use:
Hope this helps