Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Running total problem

Author  Topic 

NineIron
Starting Member

1 Post

Posted - 2011-12-09 : 14:16:12
Here is my code.......
How can I continue to get the running total if the CPT is not in a particular Post Period, considering the tables have to be joined using CPT?

select PostPeriod, NPI, provider, location, location_mapping, location_category, category, CPT, modifier, multiplier, wRVU10,
MTDCharges, MTDUnits, AdjwRVU10, MTDNetwRVU10,

(select sum(isnull(b.MTDUnits,0))
from #T2 b
where b.PostPeriod<=a.PostPeriod
and b.GroupNum=a.GroupNum
and b.NPI=a.NPI
and b.location=a.location
and b.category=a.category
and b.CPT=a.CPT
and b.modifier=a.modifier) as YTDUnits
into #T3
from #T2 a
where PostPeriod<='11103'
and category='ADMIN/INJ'
-- and NPI='1144201005'
-- and CPT='090471'
group by PostPeriod, NPI, provider, location, location_category, location_mapping, category, CPT, modifier, multiplier, wRVU10,
MTDCharges, MTDUnits, AdjwRVU10, MTDNetwRVU10

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-10 : 07:51:49
sorry cant understand the relevance of CPT here. can you illustrate with sample data?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -