Attached is a sample of 2 DRG Codes and their effective dates and two patients who have one of the 2 DRG codes.
I want to assign them their CostWeightRiw based on the DRG code and the when their DischargeDate is greater then or equal to one of the EffectiveDates and less than the next Later Date.
So in the example Patient A0000251483 has a DRG of 183 and a DischargeDate of 4/3/2010. So the CostWeightRiw would be the one for Effectivedate 10/1/2009, 1.4432.
What is the syntax to write a SQL query for the two tables DRG and DATA?