I have 2 tables where primary key of first table is used as foreign key for second table. In first table primary key is having unique values but in second table as foreign key it is having duplicate values as well. Now i want count from both the tables at same time and using left join for that. I have tried the following query :-
select distinct count(c.joined) as joined,
count(t.JobReqID),t.Country from txrecruitment as t
left join CandidateDetails as c on t.JobReqID=c.Jobreqid
where t.status='open'
group by t.Country
The count value of count(t.JobReqID) is not giving count of distinct JobReqId which i want. The result of count is counting the multiple instances of 2nd table also which i want to remove. What should be the right way to do this. Any help is welcomed!!