I have the following postgres table workExperiences:
id | userId | experience | isCurrentWorkplace
1  | 1      | xyz        | true
2  | 1      | abc        | true 
3  | 1      | wxy        | false 
4  | 2      | qwe        | false 
5  | 2      | xyz        | true 
6  | 3      | abc        | true
I want to fetch unique userIds along with the id of the table where isCurrentlyWorkplace is set to true. As each user can have multiple records with isCurrentWorkPlace to true, i am getting duplicate records.
Basically, this is the result set that i want:
id | userId | experience | isCurrentWorkplace
1  | 1      | xyz        | true
5  | 2      | xyz        | true 
6  | 3      | abc        | true
The latest record of each user where isCurrentWorkplace is set to true.
The query works fine like this and returns distinct userIds:
select distinct ("userId") from "workExperiences" where "isCurrentWorkplace" = true;
but when i select id as well, i start to get duplicate records:
select distinct ("userId"), id from "workExperiences" where "isCurrentWorkplace" = true;
how can i achieve this?
Thanks for the help in advance!
 
    