DB::raw("SELECT 'finacial_calender.id' FROM 'finacial_calender' where 'finacial_calender.F_YEAR' = 'YEAR(invoice.INV_DT)' and 'finacial_calender.F_MONTH' = 'MONTH(invoice.INV_DT)' ")
this line has an issue but my complete query is
$invoice_FlagS = DB::table('invoice')
->join('customer', 'invoice.CUST_ID', '=', 'customer.CUST_ID')
->join('cmp_dsr_products', 'invoice.DSR_PROD_ID', '=', 'cmp_dsr_products.DSR_PROD_ID')
->join('distributor_brick', 'customer.DSR_BRICK_ID', '=', 'distributor_brick.DSR_BRICK_ID')
->join('head_office_brick', 'distributor_brick.HO_BRICK_ID', '=', 'head_office_brick.HO_BRICK_ID')
->join('territory_division', 'head_office_brick.HO_BRICK_ID', '=', 'territory_division.HO_BRICK_ID')
->join('master_territory', 'territory_division.TERRITORY_ID', '=', 'master_territory.TERRITORY_ID')
->join('districts', 'master_territory.DISTRICT_ID', '=', 'districts.DISTRICT_ID')
->where('invoice.COMPANY_ID', '=', $company_id)
->whereBetween('INV_DT', [$fromDate, $toDate])
->select('master_territory.TERRITORY_ID','master_territory.DIV_ID','master_territory.DISTRICT_ID','districts.REGION_ID','cmp_dsr_products.PROD_ID','invoice.INV_QTY','invoice.INV_DISCOUNT_VAL','invoice.INV_NET_VAL','invoice.INV_DT','invoice.COMPANY_ID',DB::raw("SUM( ( CASE WHEN invoice.FLAG ='S' THEN invoice.INV_NET_VAL END ) ) AS SaleAmount"),DB::raw("SUM(abs( ( CASE WHEN invoice.FLAG ='R' THEN invoice.INV_NET_VAL END )) ) AS ReturnAmount"),DB::raw('MONTH(invoice.INV_DT)'),DB::raw("SELECT 'finacial_calender.id' FROM 'finacial_calender' where 'finacial_calender.F_YEAR' = 'YEAR(invoice.INV_DT)' and 'finacial_calender.F_MONTH' = 'MONTH(invoice.INV_DT)' "))
// ->select('distributor_product.DSR_PRODUCT_NAME','INV_ID','INV_QTY','INV_DISCOUNT_VAL',DB::raw('sum(INV_NET_VAL)AS SaleValue'))
->orderBy('invoice.INV_DT', 'asc')
->groupBy('invoice.INV_DT','invoice.DSR_PROD_ID')
->get();
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2BRHBkE
via IFTTT
Aucun commentaire:
Enregistrer un commentaire