Skip to content
Advertisement

How to get record by Date in my case using SQL Server?

I have 2 tables ProductLog and Product

ProductLog

Product

The select statement RegNo value to be ProductLog.RegNo , which is Product.Date <= ProductLog.TransDate

I want to get a result like below Expected Output

I tried by ranking order Date by ASC, and where rank =1, it set all to lowest date value. (I understand it is not a correct approach.)

what is the correct way to approach this?

Advertisement

Answer

use APPLY to find the RegNo

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