Thursday, 30 April 2015

customer and supplier name in general ledger report using case statement in sql query.


This issue is solved using case statement in sql query.
sample query:
select
       item_code, warehouse, voucher_type, voucher_no,
       CASE
            WHEN voucher_type = "Purchase Receipt" then (select supplier_name from `tabPurchase Receipt` where name=voucher_no)
            WHEN voucher_type = "Delivery Note" then (select customer_name from `tabDelivery Note` where name=voucher_no)
            ELSE " "
       END AS Name
       from `tabStock Ledger Entry`
o/p:

Inline image 2

Updated Stock Ledger Report:

Inline image 3

If any query, Please comment.

No comments:

Post a Comment