Crystal reports
SQL SERVER
I need help in changing Report 2.rpt. Such that Report2.rpt. should be reconciling and make it clear what is being reported and provide an easy way of reconciling to Report1.rpt.
In the case of Reprot2 it is slightly different to Report1.rpt in that it excludes items as follows:
1)Vouchers (ITEM.is_voucher_yn = 0)
2)Non Commission Items (ITEM.non_commission = 0)
So that this is clear Report2 should include another section AFTER to grand total called Excluded (The whole section Blank when Zero):
Vouchers (Blank when zero)
item details here
Non Commision (Blank when zero)
item details here
Sub Total and another Grand Total for Report2
The final Grand Total would reconcile to Report1.rpt Grand Total.
The SQL for both reports are same except for the WHERE clause in the REport 2 has got the above conditions.
I am looking to create one single SQL that gives me separate set of results for both conditions(preferably using CASE statements), that I can use to display results separately in my CR from the two queries below
SQL IS AS FOLLOWS:
Report 1
SELECT "sales_tx_lines"."item_qty",
"sales_tx_lines"."item_price",
FROM "sales_tx_hdr" "SALES_TX_HDR"
INNER JOIN "sales_tx_lines"
"sales_tx_hdr"."sale_tx_no" = "sales_tx_lines"."sale_tx_no"
LEFT OUTER JOIN "branch"
ON "sales_tx_hdr"."branch_no" = "branch"."branch_code"
LEFT OUTER JOIN "address"
ON "branch"."address_code" = "address"."address_code"
LEFT OUTER JOIN "item"
ON "sales_tx_lines"."item_code" = "item"."item_code"
LEFT OUTER JOIN "item_category"
ON "item"."item_code" = "item_category"."item_code"
Report 2
SELECT "sales_tx_lines"."item_qty",
"sales_tx_lines"."item_price",
FROM "sales_tx_hdr" "SALES_TX_HDR"
INNER JOIN "sales_tx_lines"
"sales_tx_hdr"."sale_tx_no" = "sales_tx_lines"."sale_tx_no"
LEFT OUTER JOIN "branch"
ON "sales_tx_hdr"."branch_no" = "branch"."branch_code"
LEFT OUTER JOIN "address"
ON "branch"."address_code" = "address"."address_code"
LEFT OUTER JOIN "item"
ON "sales_tx_lines"."item_code" = "item"."item_code"
LEFT OUTER JOIN "item_category"
ON "item"."item_code" = "item_category"."item_code"
WHERE (item.is_voucher_yn = 0 or item.non_commission = 0)
Any help is appreciated.