This is very helpful,
I want to clarify that the endDate does not exist in the Excel offer, I'm using a stored procedure that modify the endDate for the previous offer on one day before the new startdate on insert and I think that this is not logic (I need you help in this) for that I'm asking if I can remove this field from my table.
the query will be:
SELECT @rate=rate FROM
(
SELECT ROW_NUMBER() OVER( PARTITION BY Tariff_id, Prefix, Description ORDER BY StartDate DESC,id desc ) AS RW,
* FROM Tariffs t1
where startDate <= '2010-09-09'
and tariff_id= 1 and prefix ='3360042'
) x
WHERE RW = 1
and since the prefixes can
and Please can you give me an example how to insert the data in 2 tables ?