I’m having trouble with a query doing other than what I intend for it to do.
employer ID’s(eh_id) for each of the employee ID’s (pmt_id) I have in my database.
My query as it stands is as follows:
SELECT *
FROM employer_history table1
WHERE eh_id =
(
SELECT eh_id
FROM employer_history table2
WHERE table1.eh_id = table2.eh_id
group by table2.eh_id
)
and table1.eh_pmt_id in (131,3725)
What I’m getting is:
eh_id ¦ eh_pmt_id
123 ¦ 131
124 ¦ 131
125 ¦ 3725
126 ¦ 3725
What I’m expecting is:
eh_id ¦ eh_pmt_id
124 ¦ 131
126 ¦ 3725
I would appreciate any help on this as I am getting nowhere with it myself
Cheers
You can use an analytical function for this: