GPSPOW
asked on
Selecting a value based on where parameter falls within a range of dates
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?
Glen
DRG_Table.xlsx
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?
Glen
DRG_Table.xlsx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
With a little tweaking I was able to adapt it for multiple fields.
Glen