Hi everyone,Is there any other way to do this.SELECT TOP 10 C.ENCOUNTER_KEY, CA.ACTIVITY_KEYFROM (SELECT ENCOUNTER_KEY, CLAIM_KEY, ROW_NUMBER() OVER( PARTITION BY ENCOUNTER_KEY ORDER BY ISNULL(CLAIM_CREATION_DT, 0) DESC) Claim_RowNoFROM CLAIM WITH(NOLOCK)) CINNER JOIN( SELECT CLAIM_KEY, ACTIVITY_KEY, ROW_NUMBER() OVER( PARTITION BY CLAIM_KEY ORDER BY CLAIM_AMT_KEY DESC ) Claim_Amt_RowNo FROM CLAIM_AMT WITH(NOLOCK)) CAON C.CLAIM_KEY = CA.CLAIM_KEY AND Claim_RowNo = 1 AND Claim_Amt_RowNo = 1
In the above query I am fetching encounter_key order by claim_creation_dt Desc (first sub Query)and joining withlatest Claim_key order by claim_amt_key desc from claim_amt table (second sub query)from claim_amt table i want activity_key also.Please help me out...Vaibhav TIf I cant go back, I want to go fast...