साथ क्वेरी बिल्डर का उपयोग कैसे करें कैसे होगा मैं Laravel में क्वेरी बिल्डर का उपयोग निम्न SQL विवरण उत्पन्न करने के लिए:राशि() स्तंभ एवं GroupBy
SELECT costType, sum(amountCost) AS amountCost
FROM `itemcosts`
WHERE itemid=2
GROUP BY costType
मैं कई बातें की कोशिश की है, लेकिन मैं नहीं मिल सकता है sum()
कॉलम एक नाम के साथ काम करने के लिए।
मेरे नवीनतम कोड:
$query = \DB::table('itemcosts');
$query->select(array('itemcosts.costType'));
$query->sum('itemcosts.amountCost');
$query->where('itemcosts.itemid', $id);
$query->groupBy('itemcosts.costType');
return $query->get();