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

Extract Amount column into positive and negative amount columns

$
0
0

Hi there,

I have this sql

select distinct epstransactions.PatientID, sum(epstransactions.LedgerAmount)  
 from epstransactions
  inner join EPSReferralKPIs on epstransactions.PatientID = EPSReferralKPIs.dbPatID
 group by epstransactions.PatientID
 order by patientid

Whilst selecting distinct patientID's I also wish to create a posAmount and NegAmount from the LedgerAmount column as well

eg

ID          Tot      Neg       Pos
56867     100     -200      300      
56868     0         -300      300
56869    -100     -300      200


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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