Hi, i am using a query which has a sun query in it, wen i am running tat query it is giving 9332 records, I changed the sub query logic and given an inner join, but it is giving only 4476 records. So, I changed it to left join but it is giving more records than usual now, say 10033 records.
This is the code which is giving records 9332, which is correct
select distinct
b.SRC_PROV_ID
,COALESCE(a.SYSTEM_NAME, a.CTRCT_GRP_NAME, a.PROV_SMG_NAME) AS SYSTEM_NAME
INTO TINtoSystem
from
RARE.dbo.EDW_MASTER a
Inner Join RARE.dbo.EDW_PROD_ID_XREF b
on a.SMG_ID = b.SMG_ID
where SRC_PLATFORM_CD = 'TX'
and a.SMG_ID in
(
select distinct
SMG_ID
from RARE.dbo.EDW_PROD_ID_XREF
where SRC_PLATFORM_CD = 'TX'
and SRC_PROV_ID in (select q.PROV_TAX_ID from PACT.dbo.SQS_EDW_Source q)
);
I have changed this code by giving inner join as, but its not giving the exact records of 9332,
select distinct b.SRC_PROV_ID ,COALESCE(a.SYSTEM_NAME, a.CTRCT_GRP_NAME, a.PROV_SMG_NAME) AS SYSTEM_NAME INTO TINtoSystem from RARE.dbo.EDW_MASTER a Inner Join RARE.dbo.EDW_PROD_ID_XREF b on a.SMG_ID = b.SMG_ID Inner Join Pact.dbo.SQS_EDW_Source q on b.SRC_PROV_ID = q.PROV_TAX_ID where b.SRC_PLATFORM_CD = 'TX'
Can anyone tell, where it is missing, I used left join also but its giving more records then, need help