Respected Techie,
I am facing very Bizarre issue of Duplicate Record in sql Output. May someone please help me with their expertise. I am very much Thankful for your kind help.
The Problem I am facing is
I am brining column from multiple dimension table and joining with fact.
but in the output i am getting duplicate records, Unfortunately when I am using Distinct The query tooks 140 minutes to execute.
Kindly suggest if any other way possible.
I am sharing the code and error output below.
Thanks a ton Techies.
SELECT LCD.SPECIMEN_NUMBER AS SPECIMEN_NUMBER,
tod.test_ord_num,
tod.test_ord_desc,
tod.test_abbrv,
cad.SPCLTY_CD,
LCD.PATIENT_AGE_YEARS,
LCD.TOTAL_VOLUME,
tod.LAST_CHANGE_DT,
YEAR(tod.LAST_CHANGE_DT) AS Year,
MONTH(tod.LAST_CHANGE_DT) AS Month,
LCD.PATIENT_ID,
LCD.LOCATION_CD,
PD.PATIENT_CTY,
PD.PATIENT_ST,
FROM TBDW1.CONF_TEST_ORD_D AS tod
INNER JOIN TBDW1.LBTR_TEST_RSLTS_F AS trf ON tod.test_ord_srgt = trf.test_ord_srgt
INNER JOIN TBDW1.CONF_CLNT_ACCT_D AS CAD ON CAD.CLIENT_SRGT = TRF.CLIENT_SRGT
LEFT JOIN TBDW1.LBTR_LAB_SPEC_D AS LCD ON LCD.SPECIMEN_SRGT = TRF.SPECIMEN_SRGT
INNER JOIN TBDW1.LBTR_PATIENT_D AS PD ON PD.PATIENT_SRGT = trf.test_ord_srgt
WHERE LCD.PATIENT_AGE_YEARS <= 18 and tod.LAST_CHANGE_DT >= '1/1/2023'
Output with Duplicate Records :
Many Thanks
Uma