I have a massive data pull, and I have four keys I want to be able to sort on in particular.
pk.Formula.SPEEDCODE
pk.Formula.THERAPEUTIC_CLASS
pk.RxFill.PATIENT_PRICE
pk.RxFill.SHIP_DATE
Essentially, for each THERAPEUTIC_CLASS, I want to be able to pull the Top X (where X will be defined separately for each THERAPEUTIC_CLASS) SPEEDCODES (which must start with an alphanumeric character) by Sum(PATIENT_PRICE) during a specific time period corresponding to the prior Monday-Sunday week (SHIP_DATE), and then I want to list all the rest of the elements of each THERAPEUTIC_CLASS as "All Other."
I thought I had it figured out earlier, but the pulls take 6 minutes a piece, and I don't want to wait that long. Help?
Sample code:
THERAPEUTIC_CLASS SPEEDCODE PATIENT_PRICE
Pain M1 500.00
Pain NULL 125.00
Pain 85.00
Pain M1 225.00
Pain P3 600.00
Pain M1 1000.00
Pain P3 500.00
Pain P5 600.00
Pain NULL 85.00
Pain P5 450.00
Derm WART1 250.00
Derm U2 125.00
Derm NULL 225.00
Derm WART1 500.00
Derm U2 85.00
Derm 50.00
Expected Output (sorted):
TxClass Speedcode Revenue
Pain M1 1775.00
Pain P3 1100.00
Pain P5 1050.00
Pain All Other 295.00
Derm WART1 750.00
Derm U2 210.00
Derm All Other 275.00