DeveloperBreeze

Tutorials Programming Tutorials, Guides & Best Practices

Explore 148+ expertly crafted tutorials tutorials, components, and code examples. Stay productive and build faster with proven implementation strategies and design patterns from DeveloperBreeze.

Selecting the Sum of a JSON Property in MySQL

Tutorial August 17, 2024
json mysql

Similarly, if you wanted to calculate the total revenue generated by summing the price field in the JSON column, you could write:

SELECT SUM(CAST(JSON_UNQUOTE(JSON_EXTRACT(order_details, '$.price')) AS DECIMAL(10,2))) AS total_revenue
FROM orders;