Answer the question
In order to leave comments, you need to log in
How to get the sum of the cost of goods from the json array?
The database contains the following data:
id | data
1 | products": [{"price": 1000}, {"price": 2000}]
AnyModel::select(DB::raw('SUM(data->"$.products[*].price") as totalsales'));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question