Link to home
Start Free TrialLog in
Avatar of GPSPOW
GPSPOWFlag for United States of America

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
ASKER CERTIFIED SOLUTION
Avatar of TONY TAYLOR
TONY TAYLOR
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GPSPOW

ASKER

Thanks

With a little tweaking I was able to adapt it for multiple fields.

Glen