Wednesday, 2 October 2013

Breaking a single column into multiple Columns based on a condition in Sql

 select AdmnNo,ReceiptNo,
       convert(varchar(15),ReceiptDate,103) as ReceiptDate,      
       ISNULL((select SUM(CurrentPaid) from FeeReceipt where PaymentMode='cash'
       and ReceiptNo=FR.ReceiptNo and ADMNNO=FR.ADMNNO and ReceiptDate=Fr.ReceiptDate),0) as Cash,
       ISNULL((select SUM(CurrentPaid) from FeeReceipt where PaymentMode='cheque'
      and ReceiptNo=FR.ReceiptNo and ADMNNO=FR.ADMNNO and ReceiptDate=Fr.ReceiptDate),0) as Cheque
      from FeeReceipt FR
      where FR.AdmnNo=150215

No comments:

Post a Comment