Relative Content

Tag Archive for sqljoin

Join in SQL searching for the nearest identical or smaller date

I have two tables T_VEN and T_COM. In the first one I have the sales date of several products, in the second one I have the cost of these products per day. I want to join the tables to inform the cost of the product on the day of sale, but when there is no cost on that day, I want it to find the cost of the immediately previous day.