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

Computed column in SELECT CASE t-sql

$
0
0

I've got a computed column:

BilledAmount =CASEWHEN CoverageItem  in('MED','RNB','LAB')THEN  ISNULL(SUM(ISNULL(hb.BilledAmt,0)),0)ENDFROM HospitalBill hb with(nolock)

Basically, what it does is sum up the amount billed with a coverage item of for example MED from the HospitalBill table...What I wan't to do is to add another case which if the CoverageItem = 'BEN'... then the BilledAmount would be the sum of the BilledAmounts with the CoverageItem of 'LAB' and 'BEN'.. is that possible..


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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