Select	it.item_name,
				pbi.sale_price,
				SUM(pbi.sale_quantity) as sale_quantity,
				SUM(gross_sale_price) as gross_sale_price,
				SUM(pbi.cgst_amt + 	pbi.sgst_amt) AS GST,
				SUM(pbi.discount_value) as bill_discount_value,
				SUM(pbi.net_sale_price) as net_sale_price,
				sum(IFNULL(pri.return_quantity,0)) return_quantity, 
				sum(IFNULL(pri.discount_amount,0)) return_discount_amount, 
				sum(IFNULL(pri.gross_return_price,0)) return_gross_price,
				sum(IFNULL(pri.cgst_amt+pri.sgst_amt,0)) return_gst,
				sum(IFNULL(pri.net_return_price,0)) return_net_price
from 		pharmacy_billing_header pbh
inner join 	pharmacy_billing_item pbi on pbh.id = pbi.pharmacy_billing_header_id AND pbh.opd_ipd_ot_flag = 'I'
inner join	items it on pbi.item_id = it.id
INNER JOIN ipd_admission ia ON pbh.opd_ipd_no = ia.id AND	ia.id = 2
left join	pharmacy_return_items pri on (pri.pharmacy_billing_header_id = pbi.pharmacy_billing_header_id
					and	pri.pharmacy_billing_item_id = pbi.id and pri.status IN ('A', 'Y'))
group by it.item_name, pbi.sale_price