Skip to content
Advertisement

Query to pull the data from 3 tables based on latest load date and HashKey

I am trying write a SQL query to pull the data from 3 tables using JOINS on basis of common HashKey and I want to take all the updated records from 3rd table based on the load date(last increment/recent records) using SQL.

enter image description here

I have tried below SQL query but I am not able to get the recent record from third table.

I have matching number of records in Table 1 and Table 2, but there are multiple rows for same hashkey in Table3 based on loadDate.

Please provide your suggestion on this.

Thanks

Advertisement

Answer

Use ROW_NUMBER() to join only the most recent row from Table3.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement