Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
"SELECT b.trn_sno, b.bill_date, b.bill_bno, b.pt_name, b.age, b.sex, iif(d.doct_nm Is Null,'',d.doct_nm), " & _
"b.amount, iif(b.chk_free=1,b.amount,0), iif(b.chk_free=1,0,b.amount), iif(iif(b.app_ref is null,0,b.app_ref)=1,iif(iif(b.rec_ref is null,0,b.rec_ref)=1,'Refunded','Approve for Refund'),'') FROM rec_all as b LEFT JOIN doctors as d ON b.doct_id=d.doct_id WHERE " & txtfld & " and " & _
"b.rw=0 and b.co_code='" & CoCode & "' ORDER BY b.rec_ref, b.bill_date, b.trn_sno"


What I have tried:

MS ACCESS QUERY TO SQl Server 2012 change
Posted
Updated 27-Feb-17 23:33pm

1 solution

SQL
select b.trn_sno, b.bill_date, b.bill_bno, b.pt_name, b.age, b.sex,
       isnull(d.doct_nm,'') as doct_nm,case when b.chk_free=1 then b.amount else 0 end as b.amount,case when b.chk_free=1 then 0 else b.amount end as b.amount,
case when isnull( b.app_ref,0)=1 then (case when isnull(b.rec_ref,0)=1 then 'Refunded' else 'Approve for Refund' end ) else '' end  FROM rec_all as b LEFT JOIN doctors as d ON b.doct_id=d.doct_id WHERE " & txtfld & " and " & _
"b.rw=0 and b.co_code='" & CoCode & "' ORDER BY b.rec_ref, b.bill_date, b.trn_sno
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900