Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Calculating 30,60,90 Days Totals in sql

$
0
0

Hi All,

Here I  have written a query to find the total for 30Days for a perticular member after the discharge date.

These 30Days Amount will be populated into another table based on joins.

Now my question is i am trying to get the total for 60 Days , 90 Days and 180 Days.

I can write Different queries changing datediff to 60,90,180 but i want all those fields in single query .

please suggest how to write in single query.... 

Select Distinct  ip.member

sum(isnull(NetAmt,0.00)) as 30DaysAmount

from claims c

join claimsDetail cd on c.claimsnbr=cd.claimsnbr

join inpatient ip on cd.membernbr=ip.membernbr

where c.formnbr='SNF' 

and (datediff(day,cd.specificdateofservice ,dischargedate) between 0 and 30

group by ip.member

I really appreciate your help.

Thanks,

Kalyan.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>