I have 2 tables tbl_salesData
and tbl_purchasedata
. I want to get the recent purchase price from table tbl_purchasedata
into tbl_salesData
based on the col_salesdate
column. The purchase price must be before the sales date.
I need purchase price based on sales date as recent purchase date.
ex. for item Mouse the sales date is 24-07-2020 and the recent purchase price will be just before the sales date i.e, 22-07-2020 so the purchase price will be 250. The output table is like this below.
I tried but this didn't work as I am new to stored procedures and other things.
Declare @total_Count int
Declare @row_num int
set @total_Count = (select Count(*) from vw_Final_Data)
set @row_num = 1
while @total_Count < @row_num
begin
/****Some code here*****/
end
I want this to be created as stored procedure and run using scheduler.
Please help!