-1

I have three tables Lab, Payments and Transaction

enter image description here

I want to spilt transType into two columns, sum TransType Group By BillId and compare it with Lab.TotalBill to get Refundable Payments/Due payments I need SQL Query or LINQ Query please

  • Could you show the expected result? – McNets Dec 12 '16 at 8:18
0

Not sure exactly, what you are asking but this should do the first part:

SELECT BillID
,SUM(case when TransType = 'Received' OR TransType = 'Recieved' then 1 end) AS 'Number of Received'
,SUM(case when TransType = 'Refunded' then 1 else 0 end) AS 'Number of Refunded'
FROM [H+Active].[dbo].[Transactions]
GROUP BY BillID
  • I need following fields in resultsBillId, Patientname, TotalBill, Discount, Received-amount, Pending-Amount or RefundableAmount – Qasim Dec 18 '16 at 9:19
  • I need following fields in results BillId, Patientname, TotalBill, Discount, Received-amount, Pending-Amount or RefundableAmount – Qasim Dec 18 '16 at 9:20
  • In that case you could process the data in the Transactions table into a temporary table to get the total received/pending/refundable for each BillId, then just join the tables. – Jhunter1 Dec 19 '16 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.