SusanStoHelit
Technical User
Running totals through SQL.
I have a pharmacy claims database. I have a CRW 10 report using OLE DB to access a SQL server.
My report identifies members who have hit a total drug spend limit and pulls their entire claims history.
The report works great. However, now the report requestor would like me to add the date that the member hit the limit. The report is grouped by member name and drug name, not date, so any running total would be non-sequential date-wise.
I'd like to do a SQL running total formula to identify the date when the member hits the limit. This is what I have so far:
But I keep getting "Invalid column name" errors.
Any ideas?
I have a pharmacy claims database. I have a CRW 10 report using OLE DB to access a SQL server.
My report identifies members who have hit a total drug spend limit and pulls their entire claims history.
The report works great. However, now the report requestor would like me to add the date that the member hit the limit. The report is grouped by member name and drug name, not date, so any running total would be non-sequential date-wise.
I'd like to do a SQL running total formula to identify the date when the member hits the limit. This is what I have so far:
Code:
SELECT a1.ClaimID, a1.DateFill, (a1.COPAY+a1.AMOUNTDUE) as Total_Cost, SUM((a2.COPAY+a2.AMOUNTDUE)) as Running_Total
FROM TableName a1, TableName a2
WHERE Total_Cost <= Running_Total
or (Total_Cost = Running_Total and a1.ClaimID=a1.ClaimID)
GROUP BY a1.DateFill, a1.ClaimID, Total_Cost
ORDER BY a1.DateFill, Total_Cost DESC, a1.ClaimID DESC
But I keep getting "Invalid column name" errors.
Any ideas?