Riddhi Valecha

Riddhi Valecha

  • 437
  • 3.3k
  • 415.4k

Minus Query In Select Query

Sep 1 2015 4:42 AM
Hi all.. I am again stuck up...
 
I have 3 tables -
1. EMP_MASTER
2. EMP_DETAILS
3.EMP_DOCUMENTS
----------------
select * from
(
(select EM.ID ,  EM.Name , EM.Location , EM.DOJ , EM.Added_date, EM.updated_date,
ED.Salary , ED.ProjectsAssigned
from EMP_MASTER EM , EMP_DETAILS ED
where 
EM.added_date between to_date('','dd-MON-yyyy') and  to_date('','dd-MON-yyyy') )
 and EM.ID = ED.EID )
 
MINUS
 (
select EM.ID , EM.Name , EM.Location , EM.DOJ , EM.Added_date, EM.updated_date,
ED.Salary , ED.ProjectsAssigned
from EMP_MASTER EM , EMP_DETAILS ED , EMP_DOCUMENTS ED
where
EM.added_date between to_date('','dd-MON-yyyy') and to_date('','dd-MON-yyyy') )
and EM.ID = ED.EID  
and ED.DOCID = EM.ID and ED.IsDeleted = 0
)
 
)
 ------------------------
Issue -
One Emp can have multiple documents uploaded.
Now, I want only distinct records from EMP_DOCUMENTS table. 
How to put unique/distinct values in EMP_DOCUMENTS table.
 
Please guide...

Answers (3)